Thursday, 6 March 2014

First C# Windows Form Application

Hello All,

This is a very simple tutorial on how to create a Windows Form Application in c#.


Visual Studio 2008 or higher versions.

What is Windows Forms?
Windows Forms (WinForms) is the name given to the graphical application programming interface (API) included as a part of Microsoft .NET Framework, providing access to native Microsoft Windows interface elements by wrapping the extant Windows API in managed code. (Wiki definition)

So lets start.


1. Run Visual Studio and click on New Project
2. Select Windows Forms Application

3. You will get a window with an empty form. Now its your turn to design your form.
    Click on the Toolbox in the left side of the Visual Studio, you will get a list
    of controls. Now add the required control to your form (select the control from
    Toolbox and then add to your form).

4. Design your form as shown in the below screenshot.

5. Now click on the Say Hello button, and copy the below code to the window 
   named Form1.cs.Your Form1.cs will have the below code except the red colored
   one, Copy the red colored code and make your Form1.cs looks similar with this. 


using System;
using System.Windows.Forms;

namespace MyFirstWinForm
    public partial class Form1 : Form
        public Form1()
            this.Text = "Softsprogrammer"; //to set form title as "Softsprogrammer"

        private void button1_Click(object sender, EventArgs e)
            string name = textBox1.Text; //declare a string variable to hold textbox value
            MessageBox.Show("Hello " + name); //show a messagebox with "Hello " and the                                                                     //data the variable "name" holds.



6. Now Run your project, input your name and click on Say Hello button. See you got a 
    messagebox saying Hello "yourname". See the screenshot of the output


  • So you have created your first Windows Form Application. Feel free to comment if you have got any doubts or bugs in creating the project.

See Also

1 comment:

  1. Thanks for giving me a good start in C#



About Me

I am Tijo Tom, a Computer Engineer from India.Right from my schooling, I had a passion for Programming, PC Tricks, Virus Creation and Hacking.

I started this blog on Jan 1, 2014 to share my views and ideas with the world.

You can know more about me on