Let's take a look at StatusStrip: The preferred StatusStrip is a control in the form and a large control that contains a number of child controls that are stored in the control group.
So when we want to use StatusStrip, we first define the StatusStrip, then define the ToolStrip control, define the ToolStrip control group again, and third add the ToolStrip control to the control group. Four add the control group to the StatusStrip, and finally add the StatusStrip to the form.
An example is provided:
This example adds a taskbar to the form and displays test on the left side of the taskbar.
One, in the design mode of the Add method is:
Add a StatusStrip control to the form. Add a ToolStripLabel control to the StatusStrip. Sets the Text property of the ToolStripLabel control to the message that is displayed at run time (that is, test).
Second, in code mode to add the process is:
1. Define StatusStrip
2. Defining Controls (ToolStripLabel)
3. Defining the control group (ToolStripItem)
4. Add controls to the control group (Items.addrange)
5. Add StatusStrip to form
public Form1()
{
InitializeComponent();
#region AddStatusStrip
//1. 定义要增加的StatusStrip
StatusStrip sb = new StatusStrip();
//2. 定义StatusStrip项目中的控件,其中ToolStripLabel是一个相似于label的控件,现在用于显示文字
ToolStripLabel tsl = new ToolStripLabel();
//要显示的文字内容
tsl.Text = "Test";
//3. 定义StatusStrip中要项目
ToolStripItem[] tsi = new ToolStripItem[1];
tsi[0] = tsl;
//4. 将项目加入到StatusStrip中
sb.Items.AddRange(tsi);
//5. 将StatusStrip加入到窗体中
this.Controls.Add(sb);
#endregion
}