Newbie C# Question

  • Thread starter Thread starter Bruce A. Julseth
  • Start date Start date
B

Bruce A. Julseth

I created a project with a single form. Got it working Okay.. Then added a
new form to the project. I now want to make this new form as the startup
form but, apparently, it won't work because is doesn't have a "Sub Main."

I right clicked the Project then clicked Properties and checked the "Startup
Object" and the only form listed is the original form.

What do I need to do to make this new form, my "startup form?"

Thank you...

Bruce
 
In your Main() function, find where it creates an instance of your original
form. Should be something like:

Application.Run(new MyForm());

change it to:

Application.Run(new MyNewForm());

Where MyForm and MyNewForm are the class names of your two forms.

HTH
 
Copy the main method section from the first form into the second form. Edit
the main method in the second form to start the second form. Now in the
project properties, you will have both forms listed as options. In order to
be the startup form, it must have a main method. Now both forms have a main
method.

You can, if you choose, now delete the main method section in the first
form.

HTH

DalePres
MCAD, MCDBA, MCSE
 
Actually the Main method does not have to be in the same .cs file with any
form. I put mine in a separate file within the project, called
"AppMain.cs". The "startup form" is just whatever form is named in
Application.Run().

Anne
 
That is correct, but only forms with a main method will be listed as options
for the startup form in the project properties.

DalePres
 
Back
Top