Form Completely loaded and drawn?

  • Thread starter Thread starter B-Dog
  • Start date Start date
B

B-Dog

I want to run something once my form in completely loaded and drawn but
running at the end of form load doesn't do I guess cause of the large
dataset fill and the form isn't fully loaded. Where can I stick some code
so that I can run it after the form in fully drawn and loaded? I was told
there is no real way to know when it is "completely" loaded?
 
You could put it in tne form Activated Event.

'-- Use this only if you want to run it only one time
Dim run_once As Boolean
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Activated
If Not run_once Then
'--- Do whatever you want
run_once = True
End If
End Sub
 
I tried that and in my project the on activated was firing before my form
load was complete. I may be doing something wrong. Thanks
 
Yes, just tried it again and put a debug at the end of my load and a debug
on activated with activated being debugged first then load?
 
Strange, I just tried and Load got debugged first then Activate...

(Haven't played around enough to see if the form was finished drawing yet
though...)

Greg
 
The Load Event should fire before the Activated Event. What code are you
running in the load event? If you are loading a dataset as you say then you
should use a seperate thread to do that instead of the load event.
 
It's probably right but I'm putting it at then end of my form load, which
fills my dataset which must be why the activated is firing first? Don't
know but it is doing it.
 
I get the username and the fill a dataset.

Think_Fast said:
The Load Event should fire before the Activated Event. What code are you
running in the load event? If you are loading a dataset as you say then you
should use a seperate thread to do that instead of the load event.
 
I didn't think it was multi-threaded like that (is that even the term?)

I didn't think Active event could be called prior to the Load event
finishing...

Greg
 
But I think dataset fills command are sent as a separate thread so it
continues on but in reality, depending on the size of the data it is filling
it still processing. Can't do anything on my form till it is done filling
and the form thinks it is done.
 
PS: But I'm no expert at all, I'm probably blowing smoke, that is why I'm
posting.... I'm a rookie.
 

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

Back
Top