Open In App

Introduction to C# Windows Forms Applications

Last Updated : 25 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Windows Forms (WinForms) is a GUI class library for building Windows desktop applications. Originally part of the .NET Framework, it is now supported in .NET Core, .NET 5+, .NET 8 (LTS), and .NET 9. Its main purpose is to provide an easier interface to develop applications for desktops, tablets, and PCs. It is also termed as the WinForms.

The applications developed using Windows Forms or WinForms are known as the Windows Forms Applications that run on the desktop computer. WinForms can be used only to develop Windows Forms Applications.

Creating First Windows Form

Let’s create the first Windows form here we are using Visual Studio Community 2022. Refer to this article which has a complete process on how to download Visual Studio.
Firstly we create a simple form that has a button and when we click on that button it shows a message let’s create it. These are the important steps to create a Windows form follow these steps as mentioned below:

Note: At the time of writing, Visual Studio Community 2022 is the latest stable version. However, check for newer versions like Visual Studio 2025 for updated features.

Step 1: Now open Visual Studio and different options are available there as of now.

CreateNewProject


Step 2: Now choose the Windows Forms App with C# and click on the next button.

Starting


Step 3: Now locate the project with the name here we are using the default name which is Form1 and it will open a form in the editor which we can further modify.

BasicStructure

Let’s understand the interface of Visual Studio Community 2022 for Windows forms

  • Editor Window (Main Window): Here, We will work with forms and code editing. Notice the layout of the form which is now blank. If we double-click the form then it will open the code for that.
  • Solution Explorer: A file manager for your project where you can navigate between forms, resources, and settings. For example, if we will select a file from this window then particular information will be displayed in the property window.
  • Properties Window: Allows you to modify UI elements such as colors, text alignment, and visibility. Also, we can change the properties of components or controls that will add to the forms.

In the image, we have two files that are open one Design and there is Form1.cs these two play a major role. We use the Form 1.cs file for the custom logic.

Step 4: Now open a Toolbox go to the view > Toolbox or ctrl + alt + x.

Toolbox: Provides drag-and-drop controls like buttons, text boxes, and labels to design the UI.

ToolBox


Step 5. Now open the common controls and drag and drop the button on the form where we want it to be placed.

Button1working


Step 6. Now open the properties of the button press right-click on the button and it will open the properties solution explorer now we can change the button name to Click here.

Properties


Change-the-text

Step 7: Now again open the Toolbox and then click on the label and place where we want to show the message.

Label


Note: The Form1.Designer.cs file automatically generates UI code for Windows Forms. You should not manually edit this file, as changes may be lost. Instead, add event-handling logic in Form1.cs

Note: To handle user interactions, double-click a button to generate a Click event in Form1.cs. Here, you can define actions when the button is clicked.

Step 8. Now again double click on the button and it will open Form1.cs file and add the text when the button1 click action is triggered.

MessageBoxPrinting

Form1.cs file:

C#
namespace WinFormsApp2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = "Hello Geeks!";
        }

    }
}


Step 9: Now click on the start button or press F5 to execute the program.

Start


It will open a Windows form now to interact with the program.


Advantages

  • Comprehensive Controls: It comes up with a rich set of customizable controls (buttons, text boxes labels etc.) that makes it easier to use and allows more control through properties and event handling
  • Visual Designer: It comes up with the visual design helps to see the changes of form design and comes up with features like drag-and-drop for easy UI design.
  • Code Integration: A specially designed code editor for forms design helps to write application logic, handling events and data validation.
  • Use-cases: It is used in a variety of applications including the data entry tools, management system and business purposes.
  • Easy and optimal: Always become a first choice to make a lightweight desktop application for rapid development and come up with .NET support.


Next Article

Similar Reads