Call function AFTER form has been loaded

marcvs

Member
Joined
Mar 24, 2007
Messages
9
Programming Experience
1-3
Hi All!

I have a function called PopulateTree which fills a treeview with machine names on my network. This takes a couple of seconds so I put a "please wait..." in the status bar at the start of the function.

This works fine, however when I call PopulateTree on Load, the form is not displayed until the function is ready. How do I make sure my function is called after the form has been displayed?

cheers!
 
Using the Shown event instead of Load event, or a BackgroundWorker/thread.
 
another thought would be to do this in the form's Activated event and use a Boolean variable (initially set to true) to see if the form was just loaded or not, be sure to set the variable to false if it is true in your check
 
Thanks everyone for your help.

I wasn't aware of the Shown event. It seems to do the trick, although I'll still try using a separate thread for my function as the form goes blank (only) while loading.
 
Back
Top