Search code examples
c#timer

C# Loading and hiding page


I have a C# project with two forms: a loading form and a login form. The loading form has a circular progress bar and a timer that updates the progress bar until it's finished loading. When the loading form finishes loading, it's supposed to hide and the login form appears. However, I'm experiencing an issue where the loading form changes position slightly before hiding, and I'm not sure why this is happening.

I've tried some basic troubleshooting steps, such as checking the form's Anchor and Dock properties, but the issue still persists. Has anyone else experienced a similar issue when using a timer and circular progress bar and have any suggestions on how to fix it?


Solution

  • One thing I would recommend, for any project in general is not opening/closing so many forms but rather loading new forms inside a panel that is on one main form.

    This would maybe help with the jittering/glitching that you are experiencing and in general will improve the overall appearance of your application.

    To add a form to a panel:

    Form someForm = new Form();
    someForm.TopLevel = false;
    myPanel.Add(someForm);
    someForm.Show();
    

    Note that you must set the child form's top level property to false. This method of handling forms overall will reduce the opening/closing animations of your project and any graphics glitching.