Build a Windows program with good layout, and build a layout windows
After understanding the basic controls of windows, we can use these controls at a deeper level to make the layout of our form programs more reasonable.
"MenuStrip and ToolStrip in Windows
So what functions can these two controls implement?
"MenuStrip refers to the list of options that appear on the interface when the application is running. In a visualization program, you can use the menu bar to present various functions provided by the application to the user.
"ToolStrip in a Windows program, the toolbar is a region integrated with various tools for users to use.
Next, let's take a look at their main attributes and events.
Main Properties of the menu bar Control
Attribute |
Description |
Name |
Name of the menu object in the code |
Items |
Set of items displayed in the menu |
Text |
Text associated with a single dish |
Main Properties and events of menu items
Attribute |
Description |
Name |
Name of the menu item object in the code |
DropDownItems |
Set of items displayed in the sub-menu |
Text |
Text associated with the menu item |
Event |
Description |
Click |
This event is triggered when this menu item is selected. |
Set administrator form attributes
Attribute |
Value |
Description |
Name |
FrmAdminMain |
Form Object Name |
Text |
MySchool-Administrator |
Text displayed in the form title bar |
WindowState |
Maximized |
The form is the largest when it appears. |
"Form truly exits
Difference between Application. Exit () and this. Close ()
Application. Exit () |
This. Close () |
Static Method of Application, Used to exit the current application |
Instance method to close the current form. If the current form is a system startup form, Then, the application exits after the method is executed to close the form. |
If the current application opens multiple forms, Close all forms |
Only close the current form |
When the form is closed, FormClosing of the form is not triggered. And FormClosed events |
The FormClosing and FormClosed events of the form are triggered. |
----------------------------------------------------------------------------------
Main Properties of toolbar controls
Attribute |
Description |
ImageScalingSize |
Size of the image displayed for items in the toolbar |
Items |
Set of items displayed in the toolbar |
Main attributes and events of buttons and labels on the toolbar
Attribute |
Description |
DisplayStyle |
Set the display mode of images and text, including display text, Displays images, text, images, or nothing |
Image |
Images displayed on buttons/labels |
ImageScaling |
Whether to adjust the image size displayed on the button/Tag |
Text |
Text displayed on buttons/labels |
TextImageRelation |
Button/label image relative to text |
Event |
Description |
Click |
This event is triggered when a single button or tag is used. |
"Using basic WinForm controls
ReadioButton: provides a set of options consisting of two or more mutex options.
Main attributes and events of button options
Attribute |
Description |
Checked |
Indicates whether the single-choice button is selected |
Text |
Text displayed by the radio button |
Event |
Description |
Click |
A single-host Option Button occurs. |
Group box: used to provide identifiable groups for other controls. The grouping box is usually used to subscribe the form by function.
Panel: similar to the group box function, Panel is used to group controls. The only difference is that the Panel does not have a title, but the scroll bar can be displayed.
Differences between container controls GroupBox and Panel
GroupBox |
Panel |
It is used to combine a set of controls for logic, such as the R diou Button and CheckBox controls, Displays a frame with a title |
It is used to contain multiple controls to facilitate the compilation of these controls into a group for easy operation. |
DateTimePicker: provides a drop-down calendar that can be used to select a date to avoid errors caused by manual input.
Main Properties of the date Control
Attribute |
Description |
MaxDate |
Get the set maximum Date and Time |
MinDate |
Get the set minimum Date and Time |
Value |
Date/time value selected by the Control |
Format |
Used to set the format of the date and time displayed in the control |
Use the Anchor attribute
In WinForms, the Anchor attribute is provided for the control. You only need to set the Anchor attribute of the control to maintain the rationality of the control layout when the form is running.
Anchor is an Anchor that is used to set the distance between the control and a certain (several) edge of the form to remain unchanged,
This allows you to dynamically adjust the widget size as the form changes. Each control in Winforms has this attribute.
"MDI form
Significant characteristics of MDI
When you start an MDI application, the parent form is displayed first.
Parent form is the container of all other windows in the Application
Each application interface can have only one MDI parent form
Multiple subforms can be opened at any specified time
Any MDI child form cannot remove the MDI frame Area
When the MDI parent form is closed, all open MDI child forms are automatically closed.
"ComboBox control
ComboBox. Common attributes and methods of the ObjectCollection type
Attribute |
Description |
Count |
Obtains the number of items in a set. |
DorpDownStyle |
Get or set the value of the combo box style |
IsReadOnly |
Obtain the value indicating that the set can be modified |
Item |
Retrieves the specified index items in a collection. |
Method |
Description |
Add () |
Add an item to the item list in the combo box |
Clear () |
Remove all items from the combo box |
Remove |
Remove a specified item from the combo box |
Today's knowledge sharing is over! Your support is my greatest motivation!