70-526 MCTS


StatusStrip control

The StatusStrip control can be seen at the bottom of many applications, such as Internet Explorer or C# Express Edition. It allows information about objects within the application to be displayed to the user.

The StatusStrip control is a container for other controls, and it is one of these controls that allows text to be displayed just like a label. This is the ToolStripStatusLabel control and is shown here in its default state.


Inheritance hierarchy of StatusStrip

System.Object 
  System.MarshalByRefObject 
    System.ComponentModel.Component 
      System.Windows.Forms.Control 
        System.Windows.Forms.ScrollableControl 
          System.Windows.Forms.ToolStrip 
            System.Windows.Forms.StatusStrip

Inheritance hierarchy of ToolStripStatusLabel

System.Object 
  System.MarshalByRefObject 
    System.ComponentModel.Component 
      System.Windows.Forms.ToolStripItem 
        System.Windows.Forms.ToolStripLabel 
          System.Windows.Forms.ToolStripStatusLabel

Useful properties of ToolStripStatusLabel

  • AutoSize - Indicates whether the ToolStripStatusLabel is automatically resized to display all text.

  • BorderStyle - Indicates if the ToolStripStatusLabel has a border or not. Takes a value from the Border3DStyle enumeration:

    • Adjust - The border is drawn outside the specified rectangle, preserving the dimensions of the rectangle for drawing.
    • Bump- The inner and outer edges of the border have a raised appearance.
    • Etched - The inner and outer edges of the border have an etched appearance.
    • Flat - The border has no three-dimensional effects.
    • Raised - The border has raised inner and outer edges.
    • RaisedInner - The border has a raised inner edge and no outer edge.
    • RaisedOuter - The border has a raised outer edge and no inner edge.
    • Sunken - The border has sunken inner and outer edges.
    • SunkenInner - The border has a sunken inner edge and no outer edge.
    • SunkenOuter - The border has a sunken outer edge and no inner edge.

  • Enabled - If this property is set to false, the ToolStripStatusLabel appears greyed out.

  • Image - Indicates the image that is displayed on the Label control.

  • ImageAlign - Indicates the alignment of the image on the Label control. Takes a value from the ContentAlignment enumeration:

    • BottomCenter - Content is vertically aligned at the bottom, and horizontally aligned at the center.
    • BottomLeft - Content is vertically aligned at the bottom, and horizontally aligned on the left.
    • BottomRight - Content is vertically aligned at the bottom, and horizontally aligned on the right.
    • MiddleCenter - Content is vertically aligned in the middle, and horizontally aligned at the center (default).
    • MiddleLeft - Content is vertically aligned in the middle, and horizontally aligned on the left.
    • MiddleRight - Content is vertically aligned in the middle, and horizontally aligned on the right.
    • TopCenter - Content is vertically aligned at the top, and horizontally aligned at the center.
    • TopLeft - Content is vertically aligned at the top, and horizontally aligned on the left.
    • TopRight - Content is vertically aligned at the top, and horizontally aligned on the right.

  • Spring -

  • Text - The text that appears on the Label control.

  • TextAlign - Indicates the alignment of the text on the Label control. Takes a value from the ContentAlignment enumeration (see above).

    More properties can be seen when using a ToolStripStatusLabel as a web link.


    StatusStrip Items Collection Editor

    The StatusStrip Items Collection Editor is used to add, remove, and reorder ToolStripItem controls located in a StatusStrip and view and set StatusStrip and ToolStripItem properties.

    Display the StatusStrip Items Collection Editor by:

  • Right-clicking a StatusStrip control in the designer and choosing Edit Items from the shortcut menu.

  • Clicking the smart tag on a StatusStrip control in the designer and choosing Edit Items from the StatusStrip Tasks dialog box.


    Add a ToolStripStatusLabel to a Form manually

    The following example shows how to add a ToolStripStatusLabel to a Form.

    public void CreateMyToolStripStatusLabel()
    {
      StatusStrip statusStrip1 = new StatusStrip();
      ToolStripStatusLabel toolStripStatusLabel1 = new ToolStripStatusLabel();
    
      // 
      // statusStrip1
      // 
      statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[]{
        toolStripStatusLabel1});
      statusStrip1.Location = new System.Drawing.Point(0, 248);
      statusStrip1.Name = "statusStrip1";
      statusStrip1.Size = new System.Drawing.Size(292, 25);
      statusStrip1.TabIndex = 0;
      statusStrip1.Text = "statusStrip1";
    
      //
      // toolStripStatusLabel1
      // 
      toolStripStatusLabel1.Name = "toolStripStatusLabel1";
      toolStripStatusLabel1.Size = new System.Drawing.Size(246, 20);
      toolStripStatusLabel1.Spring = true;
      toolStripStatusLabel1.Text = "toolStripStatusLabel1";
      toolStripStatusLabel1.Alignment = ToolStripItemAlignment.Left;
      this.toolStripLabel1.IsLink = true;
    
    
      Controls.Add(statusStrip1);
    }

    MSDN references

  • StatusStrip control
  • ToolStripStatusLabel control


    << Previous Contents Next >>

    © Publicjoe, 2007