StatusStrip
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
| 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.
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 theToolStripStatusLabelis automatically resized to display all text.
-
-
BorderStyle- Indicates if theToolStripStatusLabelhas a border or not. Takes a value from theBorder3DStyleenumeration:
-
-
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 tofalse, theToolStripStatusLabelappears greyed out.
-
-
Image- Indicates the image that is displayed on theLabelcontrol.
-
-
ImageAlign- Indicates the alignment of the image on theLabelcontrol. Takes a value from theContentAlignmentenumeration:
-
-
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 theToolStripStatusLabelautomatically fills the available space on theStatusStripas the form is resized.
-
-
Text- The text that appears on theLabelcontrol.
-
-
TextAlign- Indicates the alignment of the text on theLabelcontrol. Takes a value from theContentAlignmentenumeration (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:
- Right-clicking a
StatusStripcontrol in the designer and choosing Edit Items from the shortcut menu. - Clicking the smart tag
on a StatusStripcontrol 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
|


