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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top