Form Loading

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

I am coming from VB6 and I want to be able to load forms (invoke form load)
without having form displayed to user. I used the Load (form) method in VB6
to accomplish this. Is there an equivilent to this in C# or is there a
different to accomplish this?

Thanks
 
There is no exact equivalent to VB's Load() method when regarding Form
loading, but in .NET using keyword "new" creates Form's instance in memory,
while in VB "new" is not strictly required (although it is bad practice
without "newing" a form).

Therefore,

Dim f As New Form1() (VB.NET) or Form1 f =new Form1() (C#)

effectively creates an instance of Form1 object. if you want to run some
initializing code when the form is created in memory but not displayed, you
could place form initializing logic in its constructor, instead of in
Form_Load event handler, because the Form_Load event does not fire until you
call Form1.Show()/ShowDialog().
 
* "mike said:
I am coming from VB6 and I want to be able to load forms (invoke form load)
without having form displayed to user. I used the Load (form) method in VB6
to accomplish this. Is there an equivilent to this in C# or is there a
different to accomplish this?

\\\
Dim f As New Form1()
///

Notice that this won't fully initialize the form.
 
Thanks for the replies. What I am trying to do is when the user opens a
file it will load each form with the data without showing the forms and then
I show the first form. Right now I open each form by showing it and I have
all these forms flickering in and out. I am looking for a way around this
like the way you could in VB6 with the Load (form) methods.

Thanks again
 
Hi Tom,

Could you let me know why the New method couldn't solve your problem?
If you need do a lot of things in OnLoad event , is it possible to move
them to the constructor?
I'd like to know more about your root problem, maybe we can find some other
way to work around it.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.
 
Back
Top