StatusStrip

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
Exam Prep. Guides
70-505 Study Guide
70-526 Study Guide

1. Forms Controls

2. Integrating Data
3. Printing/Reporting
4. Enhancing Usability
5. Asynchronous Prog.
6. Forms Controls
7. Configure/Deploy

edit
Exam 70-526 Preparation Guide: Create and configure text display controls on a Windows Form


Contents


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.


Image:526-74.jpg


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 - Indicates whether the ToolStripStatusLabel automatically fills the available space on the StatusStrip as the form is resized.
  • 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/set StatusStrip and ToolStripItem properties.

Display the StatusStrip Items Collection Editor by:

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


  2. Clicking the smart tag Image:SmartTagGlyph.jpg on a StatusStrip control in the designer and choosing Edit Items from the StatusStrip Tasks dialog box.

    Image:526-75.jpg


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


Previous_Page_.gif Next_Page_.gif
© 2007-2008 Mike Kitchen



Personal tools