can anyone help me...........

i've created a form1 with a progressbar............and i want the form1 to close at the time when the progressbar reaches 100.........and at the same time i want form2 to display............


can anyone help me to do that............

From line 41 of form1.cs :

if (progressBar1.Value == 100)
{
    Form1 f = new Form1();
    f.Hide();
    Form2 f1 = new Form2();
    f1.Show();
}

Why are you creating another form1? Did his sample code show him creating another form1? No, so don't do it.

if (progressBar1.Value == 100) {
    this.Hide();   // You are running code in form1 so 'this' is form1.
    Form2 f1 = new Form2();
    f1.Show();
}

ok in this case

if (progressBar1.Value == 100) {
    this.Hide();   // You are running code in form1 so 'this' is form1.
    Form2 f1 = new Form2();
    f1.Show();
}

when the progressbar1 reaches 100 form1 is hiding and running somewhere........even when we close form2 the whole program is not exiting since form1 is running somewhere..............

Edited 5 Years Ago by Jessurider: n/a

Yep, it's still running. If you closed form1 (form1.Close()) your whole application would stop running. If you want it to stop running after form2 is finished, change the code to:

if (progressBar1.Value == 100) {
    this.Hide();   // You are running code in form1 so 'this' is form1.
    Form2 f1 = new Form2();
    f1.ShowDialog();
    this.Close();
}
This question has already been answered. Start a new discussion instead.