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............

Recommended Answers

All 6 Replies

Perhaps something like

if (MyprogressBar.Value == 100)
{
    Form1.Hide();
    Form2.Show();
}

still the form1 is not closing..............

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..............

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();
}

yup thnks a looott................that works fine.................

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.