Hi
Is it possible to load a few forms without showing them? Also let me know the correct code for loading and unloading the Form, and Will it make showing of forms any faster when needed?
Thanks
Regards
Hi
Is it possible to load a few forms without showing them? Also let me know the correct code for loading and unloading the Form, and Will it make showing of forms any faster when needed?
Thanks
Regards
(form) FrmMain
The proper way to do this in VB.NET:
Dim frm as New FrmMain
Frm.Show
An important event you'll want to write code for is the Form Load event. You might want to, for example, set the Enabled property of a control to False when a form loads. Or maybe blank out an item on your menu. You can do all this from the Form Load event.
Add another button to your form for this example, and we'll see how the Form Load event works. (If you haven't been following along, create a new project and add two buttons to it.
Bring up your coding window, and select the Form1 Events from the drop down box.
In the events drop down box, select Load. A code stub for the Form Load event is then added to your code. Type in the following as the code for the Load Event:
MsgBox("Form Load Event")
Run your program. You should see the message box display before the Form loads.
To switch off your second Button before the Form loads, add this to your code:
Button2.Enabled = False
Run your programme again. You should see that button is no longer available for clicking on.
This loads the Form but doesn't show it.
Dim F As New Form1
It only calls the contructor (Sub New).
Then this shows it (as you know)
F.Show
It calls Form_Load (first time in) and Show.
If a Form takes a lot of time to set up then you can make it quicker in appearing by preloading. But the point at which you do your preloading will then suffer the delay! If you can arrange the loading to happen while the User is fiddling about with the UI and there are some spare CPU cycles, then a gain can be made.
I'd recommend doing some timing tests before going to a lot of trouble.
Regards,
Bookmarks