代碼在這裏,設計師窗口有一個按鈕和一個圖片框!沒有錯誤,但無法加載窗口形式的圖像
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();*/
}
}
沒有錯誤窗口打開時,當我按下按鈕,打開目錄,然後選擇的圖像,但它不能在窗口中加載圖像。 IM加載的圖像是49.6 MB,這是否會產生任何問題。
你必須在PictureBox1添加到窗體控件集合如您在禁用的代碼做了。 – 2011-05-25 12:32:12