Home »
.Net »
C#.Net »
C#.Net Windows Development
Develop a windows application in C#
In this article, we are going to learn how to develop a windows application in C#.Net? Here, we are writing the steps to create a windows application using C# in Visual Studio.
Submitted by IncludeHelp, on August 28, 2018
To develop windows application, we need to using studio and follow some steps:
Step 1) First of all we launch visual studio.
Step 2) Goto fie menu and select new project.
Step 3) Now we select "Visual C#" from left panel and select "Windows Forms Application" and give appropriate name to our application. Here I provided name "MyWinApp".
Step 4) Then A default generated form will appear in our application, like this:
Here we have following things:
- ToolBox
It contains tool to develop the application.
- Solution Explorer
It contains our project detail; it shows all files related to our project.
- Property window
Using property window we can change the properties of controls which are used in our application.
Building the solution
We can build our project or solution using build menu or shortcut key: Ctrl + Shift +B.
Execution of Application
We can execute our application with or without debugging. Here, we use debug menu or it can also be done by using shortcut key: F5 or CTRL+F5.
Design an application to display "Hello World" message on MessageBox by clicking on button control
First of all, we create a windows application. And then drag and drop a button from toolbox to container form.
We can change the name, color and text etc of any control using property window, here we change our form text to "My First Windows Application" and button text to "Click Me".
Now, we wrote code on button's click event, we can generate sample code for click event by "double click" on the button. Then the generated code will we like this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyWinApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
Here button1_Click function will use as a click event, here we can write code what we want to do on click event on the button. Now we wrote code to show MessageBox to display "Hello World".
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello World");
}
Execute application using CTRL+F5. Here is the output after clicking on the button "Click Me":