There are three reasons why we group controls:
1, in order to obtain a clear user interface and the relevant form elements are visualized grouped.
2, programming groups, such as the radio button to group.
3. To move multiple controls as a unit at design time.
In vb.net, there are three controls, GroupBox, Panel, TabControl, that can implement the three groupings mentioned above, so we call them grouped controls.
Earlier we learned about the use of the GroupBox (control Group) control (vb.net-the group control: the use of the GroupBox control), where we'll look at how to use the Panel (also called panel) control in the future. In fact, the panel is very similar to GroupBox, except that only the GroupBox control can display the caption, and only the Panel control can have scroll bars.
The Panel control icon in the Toolbox:.
First, the common properties of the Panel control
1. Anchor and Dock: These two properties are the positional properties of all controls that have a user interface.
2. Name property: Name of the object that identifies the control
3. BorderStyle property: Indicates the border style of the Panel control, with a total of three enumeration values:
BorderStyle.None (default)-No border.
borderstyle.fixed3d-three-dimensional border
borderstyle.fixedsingle-Single-line border
You can also change the appearance of the Panel control by BackColor, BackgroundImage properties.
4, font and ForeColor properties, used to change the size of the text inside the Panel control and the color of the text, it is important to note that this changes the text appearance of the Text property of the display of its internal control.
5. AutoScroll Property: This property indicates whether the scroll bar appears automatically when the control exceeds the area displayed by the Panel and defaults to false.
Ii. creating a set of controls
1. Place the Panel control on the form. Drag and drop a Panel control from the Toolbox to the appropriate position on the form to resize it.
2. Because the Panel control does not have a Text property to tag itself, we can usually add a label control to it to mark it.
3. Drag and drop other required controls within the Panel control, such as the RadioButton control.
4. Set the appearance properties of the Panel control.
4. Setup Example
Set up two panel controls on the form, marking them with 2 label controls, placing the desired RadioButton control in each panel control. One of the following:
Note: The AutoScroll property of the two panel controls is set to true.
5. When we drag a single panel control, the controls inside it move with each other to keep the relative position of the panel unchanged. Similarly, when you delete a panel control, all of the controls it contains are also deleted.
6. When we adjust the anchor and dock properties of the controls contained by the Panel control, the reference will not be the form form, but the Panel control.
7, when the AutoScroll property is True, we can also pull the scroll bar appearing in the design interface.
Iii. programming to add a panel control and the controls it contains
Adding a control dynamically typically requires the following three steps:
1. Create a control instance to add
2. Set the properties of the new control.
3. Add the control to the Controls collection of the parent control
Use of the Panel control