progressbar reaches maximum value but visually does not fill in C #

3

I'm working with a C # software, in which after a login screen, a splashscreen appears with a progressbar that when it reaches its maximum value (100) , it calls the main form of the program. The problem is that progressbar reaches the value of 100 , but visually in splashscreen , it is not fully populated (which should have reached its maximum stipulated value) and then ends up calling the next form fully charged. I'll leave the code for splash below, thanks!

Note: The sites commented on are something else you were testing so they are not relevant to the case.

private void EfectTime()
{
    //SplashTimer.Interval = 100;
    SplashTimer.Tick += new EventHandler(SplashTimer_Tick);
    SplashTimer.Enabled = true;
    //this.Opacity = 1;
}

//  private bool Efect = true;

private void SplashTimer_Tick(object sender, EventArgs e)
{   
    pgrBar.Increment(1);

    //if (Efect) 
    //{
    //    this.Opacity -= 0.01D;
    //}

    if (pgrBar.Value == 100)
    {
        //Efect = false;

        SplashTimer.Enabled = false;
        FrmTelaPrincipal frmTelaprincipal = new FrmTelaPrincipal();
        frmTelaprincipal.Show();
        this.Hide();
    }

}
    
asked by anonymous 07.11.2016 / 18:32

1 answer

2

Move the increment line to after the condition.

private void SplashTimer_Tick(object sender, EventArgs e)
{    
    //if (Efect) 
    //{
    //    this.Opacity -= 0.01D;
    //}

    if (pgrBar.Value == 100)
    {
        //Efect = false;

        SplashTimer.Enabled = false;
        FrmTelaPrincipal frmTelaprincipal = new FrmTelaPrincipal();
        frmTelaprincipal.Show();
        this.Hide();
    }

    pgrBar.Increment(1);
}
    
17.11.2016 / 19:57