Loading Form

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

Is it possible to load a few forms without showing them? Will it make
showing of forms any faster when needed?

Thanks

Regards
 
Hi John,.

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,
Fergus
 
* "John said:
Is it possible to load a few forms without showing them? Will it make
showing of forms any faster when needed?

What do you mean by "loading a form"?

You can instantiate the form class without showing the form:

\\\
Dim f As New Form1()
///
 
Run form's load event so all databindings etc (time consuming stuff) is
done. This can be done at application start-up.
 
John said:
Run form's load event so all databindings etc (time consuming stuff)
is done. This can be done at application start-up.

I don't know when databinding takes place, but you can't separate loading a
Form from showing it because "the load" happens before the Form is shown the
first time. If databinding takes place in the constructor, creating the
Form instance only - as Herfried wrote - should do the job.
 
* "John said:
Run form's load event so all databindings etc (time consuming stuff) is
done. This can be done at application start-up.

Whenever the 'Load' event is raised, the form will show. The only way
to stop this process is throwing an exception, but this won't help in
your situation.
 
Back
Top