When is a form finished loading?

T

thomasp

Using VB 2005 Beta.

I have a form containing a DataGirdView. The cell enter, cell validating,
row enter, row validating events have a good bit of code that gets excuted
for each of these events. I have noticed that when the form loads, each of
these events run 3 times, before the form is ready for interaction with the
user. I would like to set a boolean variable to true when the form first
starts loading and change it's value when the form is ready to be used.
Hopefully I can test the value of this variable before each of the events
and speed my load time up a bit. Thing is I can not find the event where I
should change the variable. I have tried FormLoaded, Activated, and
gotFocus, but the 4 events mentioned earlier still run at least once after
each of these events. Can someone tell me what the last event that a form
runs before it is ready for user interaction?


Thanks,

Thomas
 
C

Chris

Using VB 2005 Beta.

I have a form containing a DataGirdView. The cell enter, cell validating,
row enter, row validating events have a good bit of code that gets excuted
for each of these events. I have noticed that when the form loads, each of
these events run 3 times, before the form is ready for interaction with the
user. I would like to set a boolean variable to true when the form first
starts loading and change it's value when the form is ready to be used.
Hopefully I can test the value of this variable before each of the events
and speed my load time up a bit. Thing is I can not find the event where I
should change the variable. I have tried FormLoaded, Activated, and
gotFocus, but the 4 events mentioned earlier still run at least once after
each of these events. Can someone tell me what the last event that a form
runs before it is ready for user interaction?


Thanks,

Thomas

If you want to run the item once when the form is ready to display do this

In Form_Load Event
Addhandler Mybase.Activated, addressof Form_Activated

Sub Form_Activated(....)
RemoveHandler Mybase.Activated, addressof Form_Activated
'Do whatever you want to do once the form is ready show the first time

End Sub
 
C

Chris Dunaway

Chris said:
(e-mail address removed) wrote:
If you want to run the item once when the form is ready to display do this

In Form_Load Event
Addhandler Mybase.Activated, addressof Form_Activated

Sub Form_Activated(....)
RemoveHandler Mybase.Activated, addressof Form_Activated
'Do whatever you want to do once the form is ready show the first time

End Sub

Firstly, in .Net 2.0, this is no longer necessary. A form has a new
event called "Shown" which is raised the first time a form is display
and never again.

Secondly, the OP wanted to make sure that none of his grid code
executed before the form was ready. The Load event should work fine
for this.
 

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