picturebox显示图片的问题
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
PictureBox[] pic=new PictureBox[2];
for (int i = 0; i < 2; i++)
{ pic[i] = new PictureBox();
pic[i].Height =100;
pic[i].Width = 100;
pic[i].SizeMode = PictureBoxSizeMode.StretchImage;
pic[i].Location = new Point(30, 130*i);
pic[i].Image = Image.FromFile(openFileDialog1.FileName);
this.Controls.Add(pic[i]);
}
为什么这个代码第一次打开一个jpg可以顺序加载到pictureboxz中,第二次打开另外一个jpg就显示不出来,picturebox还是显示第一次加载的图片,没有刷新?
------解决方案--------------------是this.mypanel.Controls.Clear(); 上面我写错了