Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual Studio.net Project->properties doesnt show my form???

Status
Not open for further replies.

rahmanjan

Programmer
Apr 13, 2003
180
AU
hi all,

I have added some new form into my project. Now i want to use one of these forms as start up form.

I do as follow:


In Solution Explorer, right-click the project and choose Properties.

The Project property page opens with the General properties displayed.

Choosing the form you want as the startup form from the Startup Object drop-down list.


The drop down list box doesn't show my form and displays: Not set. instead. I don't know why?

I use VS.net with C#.

??

regards
 
You right. I added a new form to my app, and saw that only the first form appears in the list. Even if I write down the name of the second from, the first form continue to be loaded first.
But, I found this lines in the form1.cs:
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
I copied them to form2.cs and erased them from form1.cs, and I replaces the expression &quot;new Form1()&quot; with &quot;new Form2()&quot;, and form2 appeared first. But this caused a problem that whenever I put back the main in form1.cs, It tells me that Form2.cs is missing a main function. If the way I did it is the only way to do this, this is a bad bug. But I assume there is a better way, keep looking and I will appricate if you write the solution here.
 
Jesus Christ!!!

I never thought there might be such a bug!!! I wonder if it is registered with MS yet or not? ;0(

regards
 
Hello,

If I understand your issue correctly then korach is on the right track. The code he pasted for the Main() function launches the startup object. There can be only one of these since what you are doing is defining a Single Threaded Apartment with [STAThread]. This main function just launches the first form. If you had two forms and wanted to launch the second one instead of the first u can change the following:

Application.Run(new Form1());
TO
Application.Run(new Form2());

This may not totally clear it up, but I hope it helps. Another way to look at it is to think of it like a console application that starts in the same general fashion wiht the STAThread Main function. Something I have done that worked in the past was to add a class module my project and give it the Main function and remove it from everywhere else. Then when I want to launch a separate form I can just change it as I showed in the code above.

disassociation
 
thx a lot,

the second option is the best i think ...

regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top