[英]Resize image when control is resized c#
I have just recently started developing Windows Form Controls, and one of the controls i am currently working on is simply (for now) a picturebox with an image. 我刚刚开始开发Windows窗体控件,而我当前正在使用的控件之一只是(目前)带有图片的图片框。 But i want the user of my control to be able to rezise the image.
但我希望控件的用户能够调整图像大小。 I have tried binding the control.resize event, but it didn't seem to do the trick.
我尝试绑定control.resize事件,但似乎没有成功。
Try setting the SizeMode property. 尝试设置SizeMode属性。 More at http://msdn.microsoft.com/en-us/library/system.windows.forms.pictureboxsizemode.aspx
有关更多信息,请访问http://msdn.microsoft.com/zh-cn/library/system.windows.forms.pictureboxsizemode.aspx
Something like: 就像是:
public Form1()
{
InitializeComponent();
Resize += Form1_Resize;
}
void Form1_Resize(object sender, EventArgs e)
{
pictureBox1.Size = new Size(Width / 2, Height / 2);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.