Creating a Windows Forms Application in C#

by Shabbir on April 27, 2008

in C#

Just for start we will create very simple program, just for describing the basis of Windows Forms programming in C#.

We are using the newest version of Visual Studio, Visual Studio 2008 for programming environtment. In it is implemented the .Net Framework 3.5, but we can make projects under .Net 2.0, 3.0 and 3.5.

So, let start.

Start your Visual Studio, and in the menus go to File -> New -> Project (Ctrl+Shift+N). Then in the dialog box under the Project Types tree view select C# -> Windows, and on the right choose Windows Forms Application. Then fill the needed informations Name and Location. Then click OK.

Windows forms application create

After clicking OK, the project will be created. You will get a windows form with dimensions 300x300 pixels.

Move the cursor above the toolbox, drag one Button control and drop it on the form. You can change it's name by selecting Properties from it's context menu and change the property Text. In the properties you can find many customizations.

Double click on the button, the editor will create a Click event from the Button, and you will see code from the main form and the code from the button1 click event.

private void button1_Click(object sender, EventArgs e)
{
 
}

Then add this code between the brackets

MessageBox.Show("Hi there.\n"+
"This is a Windows Forms Application Sample!",
"Sample Message");

Now debug the application. You can do that by pressing F5.

The application will start running, click the button and the message box will pop up.

windows forms application sample

Close the message box, close the application.

This was really easy right? :)

If you don't understand something, please comment here...

Share:
  • Digg
  • Facebook
  • StumbleUpon
  • Technorati
  • Twitter

Other Related Posts

Want More Tips on How to Make Money Online?
Enter your Name and Email below to subscribe and start 1 month free course now.

Name:
Email:
You would require to confirm your email address before we send you any updates. We respect your privacy as much as you do.
Powered by Aweber
blog comments powered by Disqus

Next post:

    About the Author

  • author photo

    My Name is Shabbir Bhimani and I am developer by profession in the field of applications, web and database. Currently doing full time online marketing and like to share my experiences on how you can make money online @ CodeItWell.com. Read more ...


    See how you can get in touch with me.