简体   繁体   English

图片框SizeMode.AutoSize问题C#

[英]picturebox SizeMode.AutoSize problem C#

I'm trying to allow the user to adjust the size mode property of a picturebox on a form using radio buttons. 我试图允许用户使用单选按钮来调整窗体上图片框的大小模式属性。 It works fine for all of the size modes, center, zoom, normal etc, but when the user selects autosize, it changes, but from there it doesn't allow the user to change back to any other size modes. 它适用于所有尺寸模式,居中,缩放,普通等,但是当用户选择自动尺寸设置时,它会更改,但是从那里不允许用户更改回任何其他尺寸模式。 More rather, it does, but it simply doesn't work. 更确切地说,它可以,但是根本不起作用。

So going between any size mode that isn't autosize works, but as soon as the user selects auto size, it stays auto size. 因此,可以在任何不是自动调整大小的尺寸模式之间进行切换,但是只要用户选择自动调整大小,它就会保持自动调整大小。

 else if (autoSizeViewRadio.Checked == true)
 {
     centerViewRadio.Checked = false;
     normalViewRadio.Checked = false;
     stretchViewRadio.Checked = false;
     zoomViewRadio.Checked = false;
     pictureBox.SizeMode = PictureBoxSizeMode.AutoSize;
 }

This is an example of the code I'm using to set the sizemode. 这是我用来设置sizemode的代码示例。

See the MSDN 查看MSDN

AutoSize: The PictureBox is sized equal to the size of the image that it contains. 自动调整大小:PictureBox的大小等于其包含的图像的大小。

Source: MSDN 资料来源: MSDN

Since AutoSize makes the PictureBox the same size as the image itself, it won't make any sense that the user could change the size. 由于AutoSize使PictureBox与图像本身具有相同的尺寸,因此用户可以更改尺寸毫无意义。

AutoSize means that the PictureBox is going to fit to the image. AutoSize表示PictureBox将适合图像。 So, the other options are still working, but they have no visible affect as the PictureBox is now exactly the same size as the image. 因此,其他选项仍然有效,但是它们没有可见的影响,因为PictureBox现在与图像大小完全相同。 Personally I just wouldn't display autosize as the user shouldn't be resizing the picture box. 我个人不会显示自动调整大小,因为用户不应该调整图片框的大小。

On a side note, I think it's a bit odd that the *Picture*SizeMode property would change the size of the control, but meh, I don't know where else they would have put it aside from creating a new property just for that option. 附带一提,我认为* Picture * SizeMode属性会更改控件的大小有点奇怪,但是,我不知道他们除了为该目的创建新属性外还会把它放在什么地方选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM