Displaying a Form (C#.NET)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Greetings,

I have a "newbie" question regarding C#.NET. I am using the "Windows
Application" template and am simply trying to display a second form
("frmInstructions") once the user clicks a command button on the main form.
In the "Click" event of the command button, I have the following code:

Application.Run(new frmInstructions());

I have also tried "frmInstructions.ActiveForm.Show", but neither are
working. Can anyone tell me what I'm doing wrong?

Thanks in advance!
 
You shouldn't use the Application.Run again, it is used in main to start
your application (sort of like your "main" entry point and getting the event
loop started). Here is a sample:

on your OnClick event of the main Form:

Form2 form2 = new Form2(this);
Form2.ShowDialog(); // if its a dialog box

or

Form2.Show(); // if its not a dialog

Alex
 
Back
Top