Simple use of Winform


Mainly the following two
	"Tomorrow Technology" C#From Getting Started to Mastering the Fourth Edition (the fourth edition cannot be found online, the third edition is given here, the difference is not big, it is only for learning)
		Download link: Link: 
		Extraction code: 0925

	Learning URL:
		study Winform is need a little C#basic knowledge, but the requirements are not high, basically you can read it twice

Book download
Jump to study site

Introduction to the article

Introduce the installation and basic use of the environment (actually very simple)
Introduce common controls and corresponding events
 introduce Winform Connect database code, and commonly used data binding, etc.

Note: The following pictures are enlarged by 1 due to the problem of computer resolution.25 times, so you can click the picture to view the original picture if you can't see it clearly.

Environment installation

VS Installation is very simple, recommended VS2022,When installing, pay attention to the following points:

Official website download: (sometimes the official website is not displayed all the time, and I don't know what happened) (the official website also downloads an installer 2 MB about)

Click to jump to the official website to download VS2022

Network disk download (2 MB,a program that initiates the installation)
	Extraction code: 0925

Click to jump to the network disk to download

When installing, remember to install the following content (the installation takes a long time, because it is relatively large, it may take an hour, at this time, you can read the above books and learning websites first, of course, I recommend watching TV series to ease your mood)

Project creation instructions and common menu bar introduction

Create new project

Selected project type (to choose Framework, without Framework, the code logic inside is not the same)

Project name and storage location

Introduction to the Basic Menu Bar

Settings for themes, fonts, etc.

Introduction to the functions, properties and events of common controls

The settings described above are only some commonly used ones, and basically the default ones are fine.
	For the rest of the settings, you can slowly find the information, and then go and see how to modify it when you use it.

Here are some commonly used controls
	(The controls are named with English names, so you can guess the function according to the name, of course, just drag it over and try it out)

The introduced controls are classified into the following categories: Winform It is self-contained, and others developed later will need to learn it)
	There is a lot of the rest, it is impossible to finish it all, and I don’t understand a lot of it. Basically, the above can build some small programs and simple applications.
		You'll need to switch to something else later. Winform There is still something to learn, but it needs to be supplemented by other knowledge, such as:
			Code design (module design, design of each class), etc.

View class control

Means what you see is what you get, and is used to compose basic data sources, including the following commonly used
	ListBox Wait
I can't talk about these one by one, their usage is relatively simple, mainly because the function is relatively clear,
	Commonly used properties are in the property bar on the right, click to view

Click to view properties

Layout, menu class controls

Layout class controls usually make our program structure clearer, including the following common ones:
	TableLayoutPanel Wait

General layout controls are used in conjunction with menu controls

The common controls of the menu class are as follows:
	ContextMenuStrip Wait

Note: It is recommended to set the font of the form before the overall design, and then unify it later

Here is an example of a design layout (the design is relatively rushed, just to demonstrate the functions of each control)

Layout example (some important steps are given below, and some common properties are explained by the way)

Divided into upper and lower parts

The menu in the upper part (can use the Dock property to fill the parent container)

menu bar content items added

Another layout is shown below, with a menu bar on the left, plus a menu at the top and a content body on the right

The overall layout is as follows

data class control

exist Winform The most commonly used data class controls are the following two

DataGridView control demo

Introduction to Data Binding of DataGridView Control
If you are binding an Access database, you will be prompted to install a driver or something. Here is a version, the installation is simple, and it supports connecting to the Access database after installation. Click to jump to Access driver download
Extraction code: 0925
As for the installation of Access, directly follow the one that comes with Office. This file can be downloaded from the app store. Here is a link, CD file, download and use (but it is relatively large, 915MB), Click to download CD
Extraction code: 0925

I will not introduce the latter content of data binding, and then I personally don't like data binding, it is more troublesome, you can use code to add data

Note: due to Chart The control is more complicated, let's talk about it later, about adding through code DataGridView the way the control data,
	You can check the following article, it will be more detailed, and then it will also involve some knowledge of the database

Article link:

Click to jump to view C# database related knowledge

control event

Common events are:
	button click event
	input box response event
	node selection event
	form load event
	keyboard events, mouse events
	timed events, etc.

Notes, the addition of events, generally can be added directly through the property bar

Add events (take button event addition as an example) (double-click the button can also add events directly)
event add effect

Introduction to Design Files


The above briefly introduced Winform The installation and basic use of , many common knowledge are in the learning website mentioned above and the books of Tomorrow Technology
	Here is only a brief introduction to attracting jade, so as not to understand Winform Introduce the classmates, easy to get started
		Can be combined at the back Java There are many similarities between them

Tags: C# IDE Visual Studio

Posted by exally on Tue, 17 May 2022 01:59:23 +0300