0

I am trying to open a winForm in C# VS2012. and using this code structure for loading form. I am trying to see the loading status of form How can I do it.fm.LoadingStatus(); is for notation purpose which function i will call to show the correct loading status.

            .
            .
            formOpen = Application.OpenForms["student"];
            if (formOpen == null)
            {
                fm = new student();
                fm.TopLevel = false;
                fm.Parent = this.panel1;
                fn.Show(); //I want to show this progress in loaging bar
                int i=0;
                progressBar1.Visible = true;
                progressBar1.Value = 0;
                progressBar1.Minimum = 0;
                progressBar1.Maximum = ***fm.LoadingStatus()***;
                progressBar1.Step = 100;

                for (i = 0; i <= 100; i++)
                {
                    progressBar1.PerformStep();
                }
            }
           .
           .
Prashant
  • 394
  • 1
  • 6
  • 18
  • 1
    "I am trying to see the loading status of form " If you can see the form displayed on your screen with the `progressBar` then it is fully loaded and you can calmly write 100% – Mong Zhu Feb 28 '17 at 15:04
  • 1
    Possible duplicate of [How to use WinForms progress bar?](http://stackoverflow.com/questions/12126889/how-to-use-winforms-progress-bar) – Georg Patscheider Feb 28 '17 at 15:05
  • No not Duplicate see it, I am asking about to show the progress to form not any function – Prashant Feb 28 '17 at 15:17
  • Showing this error "Additional information: Cross-thread operation not valid: Control 'panel1' accessed from a thread other than the thread it was created on. " – Prashant Feb 28 '17 at 15:26
  • I don't think you can accurately display the progress of `Form.Show` in a percentage. Would be easier using a marquee type progress bar, this lets the user know an operation is in progress. `progressBar1.Style = ProgressBarStyle.Marquee;` – GJKH Feb 28 '17 at 15:31
  • Create an event in the student form that sends status updates at set intervals or at main points throughout the load process. Then you can just subscribe to it from your main form and update the progressbar each time it is fired. – Troy Mac1ure Feb 28 '17 at 19:36
  • Here's another thread I just found for the same as you want: http://stackoverflow.com/questions/17164707/using-a-progress-bar-on-form-load – Troy Mac1ure Feb 28 '17 at 19:38

0 Answers0