问题
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