PictureBox does not change its size

岁酱吖の 提交于 2019-12-13 01:33:07

问题


I have a PictureBox and a Button inside a Form. The PictureBox fill the Form and the SizeMode property is set to StretchImage.

When i click the button I want to change the image size (bigger), and I want also that the scrollbars appear.

So, I change the Size property of my PictureBox on the click event:

pictureBox1.Size = new Size(800, 800);

but this code does not have any effect.
Why?


I also tried to redraw the image itself (using GDI commands), but in this way the scrollbars do not appear.


How can I solve this problem? Thanks.


回答1:


Set:

pictureBox1.Bounds = this.ClientRectangle;
pictureBox1.Dock = DockStyle.None;

for your PictureBox and you will be able to resize the PictureBox itself.



来源:https://stackoverflow.com/questions/12763038/picturebox-does-not-change-its-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!