When you develop an application using C #, you typically have 6 steps to create a project, interface design, set properties, write program code, save a project, run a program, and so on.
1. Create a project
In the visual Studio2017 development environment, choose file → new → project menu, which pops up the new Project dialog box, shown in 8.1.
Figure 8.1 The New Project dialog box
You can create a Windows Forms application by selecting Windows Forms Application (. NET Framework), entering the name of the project, choosing a save path, and then clicking OK. Create the completed Windows Forms application as shown in 8.2.
Figure 8.2 Windows Forms application
2. Interface Design
After the project is created, there will be a default form in the VisualStudio 2017 development environment that allows you to design the form interface by adding various controls to it in the toolbox. To do this, press and hold the control you want to add in the toolbox, and then drag it to the specified position on the form. This example adds two label controls, two TextBox controls, and two button controls to a form, as shown in design effect 8.3.
Figure 8.3 Interface Design effect
3. Setting Properties
Select the specified control in the form, and set the corresponding property of the control in the Properties window, as shown in table 8.1.
Table 8.1 Setting properties
4. Writing Program Code
By double-clicking the two button control, you can enter the code editor and automatically trigger the button control's Click event, where you can write code that has the default code for the button control as follows:
1. on Private voidButton1_Click (Objectsender, EventArgs e)2. Geneva { 3.Geneva 4.Geneva } 5. to Private voidButton2_Click (Objectsender, EventArgs e)6. . { 7. - 8. ,}
5. Save Project
You can save the current project by clicking the button in the VisualStudio 2017 Development Environment toolbar, or by selecting the File/Save all menu.
6. Run the program
Click the button in the VisualStudio 2017 Development Environment toolbar, or choose the Debug → start debugging menu to run the current program, as shown in effect 8.4.
Figure 8.4 Program Run
This article from tomorrow's Science and Technology publishing "0 Basic C #", reproduced please indicate the source!!!
Steps for developing a Windows Forms application in C #