display picturebox
-
Hi. i want to display an gif image in picturebox cuncurrent with for().below is my code,but image dont load while for() is running. please help me.thanks.
private void button1_Click(object sender, EventArgs e)
{
PictureBox pic = new PictureBox();
pic.Image = Image.FromFile("c:\\1.gif");
this.Controls.Add(pic);for (int i = 0; i < int.MaxValue; i++) { //my work } pic.Dispose(); }
-
Hi. i want to display an gif image in picturebox cuncurrent with for().below is my code,but image dont load while for() is running. please help me.thanks.
private void button1_Click(object sender, EventArgs e)
{
PictureBox pic = new PictureBox();
pic.Image = Image.FromFile("c:\\1.gif");
this.Controls.Add(pic);for (int i = 0; i < int.MaxValue; i++) { //my work } pic.Dispose(); }
-
Hi. i want to display an gif image in picturebox cuncurrent with for().below is my code,but image dont load while for() is running. please help me.thanks.
private void button1_Click(object sender, EventArgs e)
{
PictureBox pic = new PictureBox();
pic.Image = Image.FromFile("c:\\1.gif");
this.Controls.Add(pic);for (int i = 0; i < int.MaxValue; i++) { //my work } pic.Dispose(); }
-
Hi. i want to display an gif image in picturebox cuncurrent with for().below is my code,but image dont load while for() is running. please help me.thanks.
private void button1_Click(object sender, EventArgs e)
{
PictureBox pic = new PictureBox();
pic.Image = Image.FromFile("c:\\1.gif");
this.Controls.Add(pic);for (int i = 0; i < int.MaxValue; i++) { //my work } pic.Dispose(); }
msrezapro wrote:
pic.Dispose();
what is this? pic is a control you added to this.Controls, you can't just call Dispose() on it as it is still in use. And you should dispose of images you no longer use. Hence, if you want to remove the image, do:
pic.Image.Dispose();
pic.Image=null;if you want to remove the picturebox, do:
this.Controls.Remove(pic);
possibly followed by the former code. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.