To develop windows application, we need to using studio and follow some steps:
要開發Windows應用程序 ,我們需要使用studio并遵循一些步驟:
Step 1) First of all we launch visual studio.
步驟1)首先,我們啟動Visual Studio。

Step 2) Goto fie menu and select new project.
第2步:轉到菜單,然后選擇新項目 。

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".
步驟3)現在,我們從左側面板中選擇“ Visual C#” ,然后選擇“ Windows Forms Application”,并為我們的應用程序指定適當的名稱。 在這里,我提供了名稱“ MyWinApp” 。
Step 4) Then A default generated form will appear in our application, like this:
步驟4)然后,默認生成的表單將出現在我們的應用程序中,如下所示:

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.
我們可以使用構建菜單或快捷鍵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.
我們可以在調試或不調試的情況下執行我們的應用程序。 在這里,我們使用調試菜單 ,也可以使用快捷鍵F5或CTRL + F5來完成 。
通過單擊按鈕控件,設計一個應用程序以在MessageBox上顯示“ Hello World”消息 (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.
首先,我們創建一個Windows應用程序。 然后將一個按鈕從工具箱拖放到容器窗體。

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".
我們可以使用屬性窗口更改任何控件的名稱,顏色和文本等,這里我們將表單文本更改為“我的第一個Windows應用程序” ,將按鈕文本更改為“點擊我” 。
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:
現在,我們在按鈕的click事件上編寫了代碼,我們可以通過“雙擊”按鈕來為click事件生成示例代碼。 然后生成的代碼將如下所示:
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".
在這里, button1_Click函數將用作click事件,在這里我們可以編寫代碼,以對按鈕上的click事件進行操作。 現在,我們編寫了代碼來顯示MessageBox來顯示“ 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":
使用CTRL + F5執行應用程序。 這是單擊“ Click Me”按鈕后的輸出:
翻譯自: https://www.includehelp.com/dot-net/develop-a-windows-application-in-c-sharp.aspx