Instance C #: Learning to use StatusStrip

Source: Internet
Author: User

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
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.