我正在尝试根据图片框上所选图像的分辨率来扩展表单。但是当我更改图像时,图片框的大小似乎没有改变...有什么帮助吗?
pictureBox1.ImageLocation = reader["imagem"].ToString();
pictureBox1.Height = pictureBox1.Image.Height;
pictureBox1.Width = pictureBox1.Image.Width;
/*mw and mh are the main width and main heigth,
i used this in case the user selects another
image, then the window returns to it's original
size before changing again.*/
this.Height = mh;
this.Width = mw;
this.Height += pictureBox1.Image.Height;
this.Width = pictureBox1.Image.Width + 16;
if (this.Width < mw)
{
this.Width = mw;
}
this.CenterToParent();
这只是我需要修复的部分代码。其余的都没问题,图片框显示的是我选择的图像,但它没有改变尺寸。
哦,我只是想通了,我改变了
这部分:
pictureBox1.ImageLocation = reader["imagem"].ToString();
对此:
pictureBox1.Image = Image.FromFile(reader["imagem"].ToString());
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句