代码在这里,设计器窗口有一个按钮和一个图片框!
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Open Image";
dlg.Filter = "bmp files (*.bmp)|*.bmp";
if (dlg.ShowDialog() == DialogResult.OK)
{
PictureBox PictureBox1 = new PictureBox();
PictureBox1.Image = Image.FromFile(dlg.FileName);
/* PictureBox1.Image = new Bitmap(dlg.FileName);
// Add the new control to its parent's controls collection
this.Controls.Add(PictureBox1);
//dlg.Dispose();*/
}
}
窗口打开没有错误,当我按下按钮打开目录,然后选择图像,但它无法在窗口中加载图像。即时加载的图像为 49.6 MB,是否会产生任何问题。