Form Load vs Activated Event

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

    Form Load vs Activated Event

    I thought that the Load Event fired first and the Activated event fired next
    when a control is shown. For example

    Dim myForm as New Form1

    myForm.Show

    I put a breakpoint in the load event and one in the activated event and the
    activated event fires first. I am trying to implement adding an event
    handler in the load event for the activated event then removing the handler
    in the activated event such that the activated event only fires once.

    Am I wrong in the event firing sequences?

    --
    Dennis in Houston
  • Cor Ligthert [MVP]

    #2
    Re: Form Load vs Activated Event

    Dennis,

    [color=blue]
    > Am I wrong in the event firing sequences?
    >[/color]
    There are different sequences for different situations.

    There is a page on MSDN which describes it, however it is for me as some
    other obvious pages as about the methods in the microsoft namespace almost
    impossible to find direct. Maybe can you try it yourself.

    Cor



    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Form Load vs Activated Event

      "Dennis" <Dennis@discuss ions.microsoft. com> schrieb:[color=blue]
      >I thought that the Load Event fired first and the Activated event fired
      >next
      > when a control is shown. For example
      >
      > Dim myForm as New Form1
      >
      > myForm.Show
      >
      > I put a breakpoint in the load event and one in the activated event and
      > the
      > activated event fires first. I am trying to implement adding an event
      > handler in the load event for the activated event then removing the
      > handler
      > in the activated event such that the activated event only fires once.[/color]

      You may want to add the handler in the form's constructor after the call to
      'InitializeComp onent'.

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      • Dennis

        #4
        Re: Form Load vs Activated Event

        I could do that but I want to initialize some things in the Activated method
        like setting a combobox.select edindex to a value but I get an error because
        the load event hasn't executed, the combobox is unavailable.
        --
        Dennis in Houston


        "Herfried K. Wagner [MVP]" wrote:
        [color=blue]
        > "Dennis" <Dennis@discuss ions.microsoft. com> schrieb:[color=green]
        > >I thought that the Load Event fired first and the Activated event fired
        > >next
        > > when a control is shown. For example
        > >
        > > Dim myForm as New Form1
        > >
        > > myForm.Show
        > >
        > > I put a breakpoint in the load event and one in the activated event and
        > > the
        > > activated event fires first. I am trying to implement adding an event
        > > handler in the load event for the activated event then removing the
        > > handler
        > > in the activated event such that the activated event only fires once.[/color]
        >
        > You may want to add the handler in the form's constructor after the call to
        > 'InitializeComp onent'.
        >
        > --
        > M S Herfried K. Wagner
        > M V P <URL:http://dotnet.mvps.org/>
        > V B <URL:http://classicvb.org/petition/>
        >
        >[/color]

        Comment

        Working...