Load events happens at strange times

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • **Developer**

    Load events happens at strange times

    I have a Form (FV&C) containing a userconrtrol (CF&E)

    I do a ShowDialog for the form and the form's Load calls a method of the
    UserControl.

    The first time I do this the usercontrol appears on the form as I'd expect
    after the method had been run.

    The second time I do this the usercontrol appears on the form as if the
    usercontrols Load had last been run.

    I peppered the code with writes and the following resulted.

    Note that for the fist time, the usercontrol's Load runs before the form's
    Load starts.

    But, notice at the bottom of the list that for the second time, the
    usercontrol's Load runs after the form's Load ends.

    Does this make sense to you?

    Any suggestions as to what is going on?

    I need to have the CF&E Load run before the called method or better, if the
    usercontrol remember from the last time, not to run at all.

    Thanks


    FV&C New Staring
    CF&E New Staring
    CF&E New Ending
    FV&C New Ending
    Call FV&C method
    FV&C.ShowDialo g
    CF&E Load Staring
    CF&E Load Ending
    FV&C Load Staring
    Called a method in CF&E
    FV&C Load Ending
    FV&C Closing
    FV&C.ShowDialo g Returned
    Call FV&C method
    FV&C.ShowDialo g
    FV&C Load Staring
    Called a method in CF&E
    FV&C Load Ending
    CF&E Load Staring
    CF&E Load Ending
    FV&C Closing
    FV&C.ShowDialo g Returned



  • tomb

    #2
    Re: Load events happens at strange times

    **Developer** wrote:
    [color=blue]
    >I have a Form (FV&C) containing a userconrtrol (CF&E)
    >
    >I do a ShowDialog for the form and the form's Load calls a method of the
    >UserControl.
    >
    >The first time I do this the usercontrol appears on the form as I'd expect
    >after the method had been run.
    >
    >The second time I do this the usercontrol appears on the form as if the
    >usercontrols Load had last been run.
    >
    >I peppered the code with writes and the following resulted.
    >
    >Note that for the fist time, the usercontrol's Load runs before the form's
    >Load starts.
    >
    >But, notice at the bottom of the list that for the second time, the
    >usercontrol' s Load runs after the form's Load ends.
    >
    >Does this make sense to you?
    >
    >Any suggestions as to what is going on?
    >
    >I need to have the CF&E Load run before the called method or better, if the
    >usercontrol remember from the last time, not to run at all.
    >
    >Thanks
    >
    >
    >FV&C New Staring
    >CF&E New Staring
    >CF&E New Ending
    >FV&C New Ending
    >Call FV&C method
    >FV&C.ShowDialo g
    >CF&E Load Staring
    >CF&E Load Ending
    >FV&C Load Staring
    >Called a method in CF&E
    >FV&C Load Ending
    >FV&C Closing
    >FV&C.ShowDialo g Returned
    >Call FV&C method
    >FV&C.ShowDialo g
    >FV&C Load Staring
    >Called a method in CF&E
    >FV&C Load Ending
    >CF&E Load Staring
    >CF&E Load Ending
    >FV&C Closing
    >FV&C.ShowDialo g Returned
    >
    >
    >
    >
    >[/color]
    My guess is you are not using a form variable, but rather loading the
    form directly. Using a form variable, you will then call New, and the
    process should proceed as in the first portion.

    Tom

    Comment

    • **Developer**

      #3
      Re: Load events happens at strange times

      Maybe the problem is because I use the same Form variable for two
      ShowDialog's.
      As normal with ShowDialog, the form is closed at the end of the first
      ShowDialog run.
      What happens the second time I do ShowDialog

      I think that must be the problem.
      I want to keep the form around because it contains data that I need.
      So I do ShowDialog on the form
      The form closes itself when finshed
      I do ShowDialog later thinking ( maybe not thinking clearly) that my data
      will still be there and the form will simply become visible.



      In Declarations I do
      Friend WithEvents mFormVolAndChap s1 As CAG.formVolAndC haps.FormVolAnd Chaps =
      New CAG.formVolAndC haps.FormVolAnd Chaps



      On menuitem click event I do

      Console.WriteLi ne("Call FV&C method")

      mFormVolAndChap s1.Action =
      FormVolAndChaps .FormVolAndChap s.ActionType.Cr eateNewVolumeFo lder

      Console.WriteLi ne("FV&C.ShowDi alog")

      mFormVolAndChap s1.ShowDialog()

      Console.WriteLi ne("FV&C.ShowDi alog Returned")

      ' It's the second time I click that I have a problem.

      ' I've noticed that the usercontrol Visible property is True the
      first time and False the second time!




      Comments?

      I believe the above procedure would be OK if I were using Show instead of
      ShowDilog - correct?


      Thanks




      "tomb" <tomb@technetce nter.com> wrote in message
      news:DpEpf.6602 $k76.2077@bigne ws6.bellsouth.n et...[color=blue]
      > **Developer** wrote:
      >[color=green]
      >>I have a Form (FV&C) containing a userconrtrol (CF&E)
      >>
      >>I do a ShowDialog for the form and the form's Load calls a method of the
      >>UserControl .
      >>
      >>The first time I do this the usercontrol appears on the form as I'd expect
      >>after the method had been run.
      >>
      >>The second time I do this the usercontrol appears on the form as if the
      >>usercontrol s Load had last been run.
      >>
      >>I peppered the code with writes and the following resulted.
      >>
      >>Note that for the fist time, the usercontrol's Load runs before the form's
      >>Load starts.
      >>
      >>But, notice at the bottom of the list that for the second time, the
      >>usercontrol 's Load runs after the form's Load ends.
      >>
      >>Does this make sense to you?
      >>
      >>Any suggestions as to what is going on?
      >>
      >>I need to have the CF&E Load run before the called method or better, if
      >>the usercontrol remember from the last time, not to run at all.
      >>
      >>Thanks
      >>
      >>
      >>FV&C New Staring
      >>CF&E New Staring
      >>CF&E New Ending
      >>FV&C New Ending[/color][/color]
      [color=blue][color=green]
      >>Call FV&C method
      >>FV&C.ShowDial og
      >>CF&E Load Staring
      >>CF&E Load Ending
      >>FV&C Load Staring
      >>Called a method in CF&E
      >>FV&C Load Ending
      >>FV&C Closing
      >>FV&C.ShowDial og Returned[/color][/color]
      [color=blue][color=green]
      >>Call FV&C method
      >>FV&C.ShowDial og
      >>FV&C Load Staring
      >>Called a method in CF&E
      >>FV&C Load Ending
      >>CF&E Load Staring
      >>CF&E Load Ending
      >>FV&C Closing
      >>FV&C.ShowDial og Returned
      >>
      >>
      >>
      >>[/color]
      > My guess is you are not using a form variable, but rather loading the form
      > directly. Using a form variable, you will then call New, and the process
      > should proceed as in the first portion.
      >
      > Tom[/color]


      Comment

      Working...