如何获取来自 ImageLocation 的图片框图像的宽度和高度?

How do I get width and heigth of picturebox image coming from ImageLocation?

我正在尝试根据图片框上 selected 图像的分辨率来扩展我的表单。但是当我更改图像时,图片框的大小似乎没有改变...有帮助吗?

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();

这只是我需要修复的部分代码。其余的都很好,图片框显示的是我的图片 select,但它没有改变大小。

哦,伙计们,我刚刚弄明白了,我改变了

这部分:

pictureBox1.ImageLocation = reader["imagem"].ToString();

为此:

pictureBox1.Image = Image.FromFile(reader["imagem"].ToString());