Form

  • Thread starter Thread starter BJ
  • Start date Start date
B

BJ

Hi,

I have created a MainForm and another form called "Form2" statically. I
would like to call Form2 from MainForm, how do I do this?

I have tried in MainForm:

Form2.ActiveForm.Show();

But no luck.
 
BJ said:
Hi,

I have created a MainForm and another form called "Form2" statically. I
would like to call Form2 from MainForm, how do I do this?

I have tried in MainForm:

Form2.ActiveForm.Show();

But no luck.

From MainForm do this:

Form2 myForm = new Form2(); //which calls the form2 constructor

//and then simply
myForm.ShowDialog();
 
2004-7-6 0:59:22


<[email protected]>


Hi,

I have created a MainForm and another form called "Form2"
statically. I
would like to call Form2 from MainForm, how do I do this?

I have tried in MainForm:



But no luck.



You can do this:

new Form2().Show();

or

new Form2().ShowDialog();



You can't call Form2 statically, you must make an instance of class
Form2.
 
Back
Top