Sunday, August 2, 2009

How to set start up form in c#.net?

Assuming you know how to use the command line to compile or using an IDE:





using System;


using System.Windows.Forms;





namespace MyNamespace


{


class Program


{


[STAThread]


static void Main()


{


Application.Run(new Form());


}


}


}





This code will create a new System.Windows.Forms.Form and run it. You will have to extend the Form class and add the controls you want and then run a new instance of that class instead of Form.





Alternatively,


Download Visual C# 2008 Express from


http://www.microsoft.com/express/vcsharp...


and you can create a Windows Form Application and Visual C# 2008 Express will generate the base code for your form. You can then use the builtin designer to easily create your own form.

How to set start up form in c#.net?
In visual Studio, you set it in the project properties.





In the SDK





Quick example without VS:





namespace Microsoft.Samples.WinForms.Cs.SimpleHell... {


using System;


using System.Windows.Forms;





public class SimpleHelloWorld : Form {





[STAThread]


public static int Main(string[] args) {


Application.Run(new SimpleHelloWorld());


return 0;


}





public SimpleHelloWorld() {


this.Text = "Hello World";


}


}


}


No comments:

Post a Comment