Form Load vs Activated Event

G

Guest

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?
 
C

Cor Ligthert [MVP]

Dennis,

Am I wrong in the event firing sequences?
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
 
H

Herfried K. Wagner [MVP]

Dennis said:
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.

You may want to add the handler in the form's constructor after the call to
'InitializeComponent'.
 
G

Guest

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top