none
if progressbar 100% then load form2 and exit. RRS feed

All replies

  • Hi William,

    Thank you for posting here.

    Based on your description, you want to exit form1 and load form2 when the progressbar's value is 1.

    You could try the following code:

     private void Button1_Click(object sender, EventArgs e)
            {
    
                progressBar1.Visible = true;
                progressBar1.Minimum = 1;
                progressBar1.Maximum = 100;
                progressBar1.Value = 1;
                progressBar1.Step = 1;
                for (int i = 0; i < 100; i++)
                {
                    progressBar1.PerformStep();
                    if (progressBar1.Value == progressBar1.Maximum)
                    {
                      
                        Form2 form2 = new Form2();
                        form2.Show();
                        this.Hide();
                        break;
    
                    }
                }
            }

    Result:

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, June 24, 2019 2:59 AM
    Moderator