PictureBox不会更改其大小 [英] PictureBox does not change its size
问题描述
我在Form
中有一个PictureBox
和Button
. PictureBox
填充Form
,并且SizeMode
属性设置为StretchImage
.
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.
因此,我在点击事件上更改了PictureBox
的Size
属性:
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?
我还尝试过使用GDI命令重绘图像本身,但是这种方式不会显示滚动条.
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.
推荐答案
设置:
pictureBox1.Bounds = this.ClientRectangle;
pictureBox1.Dock = DockStyle.None;
(对于PictureBox
),您将能够调整PictureBox
本身的大小.
for your PictureBox
and you will be able to resize the PictureBox
itself.
这篇关于PictureBox不会更改其大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!