The grouping class control mainly includes controls such as container control (Panel), Group box control (GROUPBOX), and tab control (TabControl).
One, the Panel control
The Panel control is provided by the System.Windows.Forms.Panel class, and the primary role is to put the other controls together on one panel, making these controls easier to manage. You can set the AutoScroll property to True when you want to display too many controls on the Panel control panels.
The Panel control does not display a border by default, such as by setting the BorderStyle property to another value other than none, you can use panels to visually combine related controls.
Example: Demo Panel control's BorderStyle property and AutoScroll property
(1) Add a Panel control to the form, set the AutoScroll property to True, set the BorderStyle property to Fixed3D, add a button control, and a ListBox control, Sets the Text property of the button control to "increment".
(2) Double-click the button control to generate the Click event, complete adding an item to the ListBox control in the Click event and increase its height by 20, the code is:
<span style= "FONT-SIZE:18PX;" > private void Button1_Click (object sender, EventArgs e) { listBox1.Items.Add ("subkey");//Add child Listbox1.height = listbox1.height + 20;//Increase height }</span>
The complete Form code is:
<span style= "FONT-SIZE:18PX;" >using system;using system.collections.generic;using system.componentmodel;using System.Data;using System.drawing;using system.linq;using system.text;using system.threading.tasks;using System.Windows.Forms; namespace windowsformsapplication3{public partial class Form1:form {public Form1 () { InitializeComponent (); } private void Button1_Click (object sender, EventArgs e) { listBox1.Items.Add ("subkey");//Add child Listbox1.height = listbox1.height + 20;//increase height } }}</span>
Run the form and click the Add button multiple times to result in:
Two, GroupBox control
The GroupBox control is provided by the System.Windows.Forms.GroupBox class, and the primary role is to provide a recognizable grouping for other controls, typically by using the group box to subdivide the form by function.
Example: Demonstrating the use of GroupBox controls
On the form, add the two GroupBox controls Gpbsystem and Gpbclass, set the Text property of the Gpbsystem control to a line, and place two RadioButton controls, setting their Text property to computer and foreign language department, respectively. Also set the Text property of Gpbclass to class, and place two RadioButton controls, setting their Text property to "one shift" and "Class Two", respectively.
The result of running the form is:
Three, TabControl controls
TabControl controls are provided by the System.Windows.Forms.TabControl class to group related components onto a range of tab pages. The TabControl control manages the TabPages collection, and the Multiline property of the TabControl control is used to set whether the multiline option Kashun is displayed. If the multiline property is set to False, and multiple tabs cannot be displayed at one time, the group arrows are provided to view the remaining tabs. The Appearance property of the TabControl control is whether the tab is a Swing button or a General tab, with three values of normal (drawn as General options), Buttons (drawn as regular), and Flatbutton (drawn as smooth buttons).
By placing the cursor on the TabControl control, you can add and remove TabPages collections by adding tabs or by selecting the Remove tab command, or you can add and remove TabPages collections by TabControl control TabPages properties. The Text property of the TabPages is used to set the content displayed on the tab. The Selectedtab property can determine the current tab. Each time you select a new tab, the ambulance triggers the SelectedIndexChanged event, confirming the current selection with the SelectedIndex property and the Selectedtab property, which can be processed according to the tab.
Example: Demonstrating the use of TabControl controls
(1) Add a TabControl control on the form and right-click, select "Add Tab" command, add a tab TabPage1, repeat the action add a TabPage2, add a button control in TabPage1, Change the Text property of TabPage1 to "option One", add a TextBox control in TabPage2, and change the Text property of TabPage2 to "option two".
(2) Select the TabControl control, find the SelectedIndexChanged event in the event, double-click the trailing space, generate the SelectedIndexChanged event, Displays the title and index of the TabPages of the TabControl control's options through the Show method in the MessageBox, with the following code:
<span style= "FONT-SIZE:18PX;" > private void Tabcontrol1_selectedindexchanged (object sender, EventArgs e) { MessageBox.Show ("You clicked" +tabcontrol1.selectedtab.text //cancels the clicked tab title + "Its index is" +tabcontrol1.selectedindex.tostring ());//Cancel Click Tab index }</span>
The complete form code is:
<span style= "FONT-SIZE:18PX;" >using system;using system.collections.generic;using system.componentmodel;using System.Data;using System.drawing;using system.linq;using system.text;using system.threading.tasks;using System.Windows.Forms; namespace windowsformsapplication5{public partial class Form1:form {public Form1 () { InitializeComponent (); } private void Tabcontrol1_selectedindexchanged (object sender, EventArgs e) { MessageBox.Show ("you clicked" + TabControl1.SelectedTab.Text //cancels the clicked tab title + "Its index is" +tabcontrol1.selectedindex.tostring ());// Cancels the Clicked Tab index } }}</span>
Click the tab to run the result as:
WinForm control's grouping class control