开发者

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, bu开发者_运维技巧t 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.


See the MSDN

AutoSize: The PictureBox is sized equal to the size of the image that it contains.

Source: 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 means that the PictureBox is going to fit to the image. 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. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜