Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

how to set start up page in windows application using c#.net

Dec 20, 2010
Introduction:

Here I will explain how to set start up page in windows application using c#.net.

Description:

I have worked on web applications in asp.net I didn’t worked on windows application one day we got requirement to work on windows application at that time I don’t’ know anything about windows application even how to set startup page in windows application. I have searched many websites for this after search long time I found answer for this partially.

At that time I decided to write this post because some of the people who don’t know how to set start up page in windows application for those people it gives idea to set start up page.
Open visual studio and create new windows application by default it will create Form1.CS page now if we run application Form1.CS runs by default but if we add another page to our project and we need to set that page as start up page at that time we will get problem for that we need to follow these steps.
To set our page as start up page that page needs to contain following code in

***************************************
static void Main()
{
Application.Run(new YourFormName());
}
***************************************

Application.Run(Form) method: Begins running a standard application message loop on the current thread, and makes the specified form visible.

YourFormName() add your form name (whatever the page name you have given at the time creation of page) and Add this Main () method in all of your pages after that you will get all the pages list in Startup object list there we have chance to select particular page as start up page. After completion of adding this Main method follow the below steps

1.    Right click on your project select properties
2.    Select Application tab in that you will find Startup object combo box
3.    This combo box contains list of forms which is having method Main ().
4.     Select Form(whatever the Form you need to set as start up form)

In combobox if you select option (Not set) you will get error like Program has more than one entry point defined to remove error we need to select at least one form by default this combobox contains yourapplciation.Program  form as Startup object.

Demo


If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

9 comments :

Anonymous said...

Just open program.cs and change the form name.

Shrikanth.T.M said...

Awesome Articles...help full for freshers as well as professional working on different type projects ..web and windows

Anonymous said...

thank you

Akhil Dave said...

HI suresh,,,, can write a article on CHATTING (ASp.net c#) like social networking sites,,,

http://techterabyte.blogspot.in/
A blog on Asp.net, oracle, sql

Anonymous said...

Thanks a lot....it really helped

Anonymous said...

nice one.. thank u.. it solved my problem

Priya Mahindrakar said...

i unable to download SQL Compact version ... shall i use mirosoft SQL SERVER DATABASE FILE.... in connection hich include SQL Express

Anonymous said...

thnx a lot very very much

Sameer Rane said...

hello, i want to run my form2 1st as splashscreen n den my form1 as login form... so m enable to do dat...C#.net in visual studio dosnot contain my form in startup object which u have shown in demo... to is der any another way to run my form2 1st wen it compile...plzz help

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.