Form Load and showing form while it is loading

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rb0135
    New Member
    • Jan 2010
    • 20

    Form Load and showing form while it is loading

    Hi,

    I am writing a C# mobile 6 (dot.net 3.5) application.

    On the form, I have a label. I update this label with text as my initalizing routines are running (from the form load event), such as initializing the database, setting variables, setting up the GPS, etc.

    That is why I want the form to display first,so that when my routines (in the form load event) run, I want the label to update with text such as "Initializi ng the database".

    I can update the label, but the form is never shown until everything has run and all that occurs is the wait cursor showing.

    I have tried everything, like this.show and an application doevents in the form load event, but it wont physically show the form until all the routines in the form load routine have completed.

    I have tried form activate as well, but that exhibited the same behaviour as the form load.

    Is there anyway to halt processing until the form is displayed, or is there another command other than this.show.

    Is there a different way to actually know the form is displayed before proceding?

    Any ideas?

    Thanks,
    Robert
  • markmcgookin
    Recognized Expert Contributor
    • Dec 2006
    • 648

    #2
    Once you have done the text change for the lable you might want to try refreshing the lable to see if that will redraw it.

    Code:
    this.lable1.text = "SomeText";
    this.lable1.Refresh();

    Comment

    • rb0135
      New Member
      • Jan 2010
      • 20

      #3
      Thanks for the help.

      When I first read your response, i was going to reply that I am not even seeing the form and was wondering why the refresh would work.

      However, I went and tried the code, but I mistyped and put

      this.refresh();

      rather than refreshing the label.

      Well, this.refresh(); worked for the form and seems to show it, and, when I am updating the label, it works a treat.

      So, thanks for the info, it is working now as I was hoping..

      Thanks,
      Robert

      Comment

      • markmcgookin
        Recognized Expert Contributor
        • Dec 2006
        • 648

        #4
        Ok, that will redraw the entire form though, it might be a bit faster to just refresh the lable.

        this.Refresh(); will do everything on the form

        whereas this.Lable1.Ref resh(); will just to the lable on its own.

        Glad it worked out for you anyway!

        Comment

        • rb0135
          New Member
          • Jan 2010
          • 20

          #5
          Thanks for the advice.

          I only have three controls.

          BUT

          I wanted to do this right, and by refreshing the label only does produce the same results are refreshing the whole form...

          That is: getting it to display.

          Thanks again,
          Robert

          Comment

          Working...