1. Introduction to C# StatusStrip Control
‘StatusStrip’ is a group of strip controls like MenuStrip and ToolbarStrips. Application Developers uses the StatusStrips to display some quick status data to the user. A C# StatusStrip Control will look like the one shown below:

C# StatusStrip At a Glance
C# StatusStrip Control allows us to add even combo and text boxes to the status. In this example, we will learn how to add a Status Bar to a C# Application with three status slots in it. Then we will look at some important properties and use that efficiently.
2. About The Example
The screenshot of the Example is below:

C# StatusStrip Example
In the above example, the black colored narrow strip is the StatusStrip, and it has three slots in it. The computation section will calculate the sum of the number which we enter inside the text box. On iteration of the numbers, a delay is introduced to simulate that it is a long-running process. During this time, ‘Computing please wait’ will appear in the first status slot. The second slot will show current border style of the status bar and the third one shows user’s last input given in the text box.
We can set two kinds of border style to the status bar using the Border Style section. After picking the border style, one can apply that style to top or left or even all four edges of the status bar using the ‘Apply To’ section of the example. When user removes the check mark, we will revoke the style.
The spring check boxes allow expanding the slot to occupy the remaining free space. We will start our Example now.
3. Adding Status Bar and Status Slots
One can spot the StatusStrip control in the Menus & Toolbar section of the Toolbox in the Visual Studio. First, we should add this control to the form. Second, we add three status labels to it using the ‘Edit Items’ option of the status bar. Then inside the property dialog, we set the name for each status slot. This is shown in the below video:
4. Assigning Initial Texts in The Status
We can access the StatusLabel in the status bar directly by its name. In the form load event handler, we are placing some initial text to it. Below is the event handler code:
1 2 3 4 5 6 7 8 |
//Status 001: Set status Labels private void StatusBarSample_Load(object sender, EventArgs e) { //Access the Status Labels by Name SLabel1.Text = "Idle"; SLabel2.Text = "Default"; SLabel3.Text = "0.0"; } |
SLabel1
to
SLabel3
is added in the previous step and its text property is set during the form load. So, the initial display of the form will show above set texts in the status labels. The below video shows the status bar with initial values:
5. Showing Informative Text in Status Bar
When is it required to show informative text? Say when the application is doing a long-running task, we may need to inform this to the user. Some people display an hourglass icon and some display a ‘Please Wait…’ message in the status bar. We will display this message in the Status Bar. The compute button will calculate the summation of number entered by the user. We use ‘
Thread.Sleep
’ to mimic this as a long-running task. The ‘Compute Summation’ button click handler is below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
//Status 002: Compuate Summation private void btnSum_Click(object sender, EventArgs e) { //Status 002_1: Declarations and some initialization long endno = long.Parse(txtInput.Text); long sum = 0; lblResult.Text = ""; //Status 002_2: Set the text for status and start computation. Do not forget Application.doevents() SLabel1.Text = "Computing Please Wait.."; for (long cnt = 1; cnt < endno + 1; cnt++) { Thread.Sleep(10); Application.DoEvents(); sum = sum + cnt; } lblResult.Text = sum.ToString(); //Status 002_3: Set the status as Idle SLabel1.Text = "Idle"; SLabel3.Text = "Last Input: " + txtInput.Text; } |
In the above code, the
Thread.Sleep(10);
is used to hang the sample for 10 milliseconds in each iteration. Before the simulated long process starts, we are displaying the status message using the statement:
SLabel1.Text = “Computing Please Wait..”;
and at the end, we are changing the status label to ‘Idle’ meaning that the application is not busy. Also, we are setting the input given by the user in the third status slot.
We should note that even though we set the status label ‘Computing Please Wait…’, it will not get displayed when the application is too busy. This means, when the application is busy, it has no time to render any user interface changes. Hence, displaying information text in the status label text appears only when the application goes back to normal state. In effect, our user never sees the message, ‘Computing Please Wait…’ in the First Status Slot. To avoid this, we call
Application.DoEvents()
. It will notify windows to process any pending UI redraw. In our case, windows form will see that it needs to render the text, ‘Computing Please Wait…’ in status slot. How the status label informs the busy message to the user is shown in the below video:
6. Applying and Revoking Border Style of the Status Slots
Note that in section 3 of this article we added three
ToolStripStatusLabels
to our C# StatusStrip Control. In this section, we will set the border style to the edges of these status labels.
The table below shows all the available ‘Border Styles’. In this Example, we will take only two of them for testing. In this section, we will see how to apply the ‘Border Styles’ and then how to revoke it.
Member name | Description |
---|---|
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. |
6.1 ToolStripStatusLabelBorderSides Enumeration
ToolStripStatusLabelBorderSides
Enumeration specifies which side of the status slot is having the border style. The below table describes enumeration values:
Constant | Value | Description |
---|---|---|
All | 15 | All sides of the ToolStripStatusLabel have borders. |
Bottom | 8 | Only the bottom side of the ToolStripStatusLabel has borders. |
Left | 1 | Only the left side of the ToolStripStatusLabel has borders. |
None | 0 | The ToolStripStatusLabel has no borders. |
Right | 4 | Only the right side of the ToolStripStatusLabel has borders. |
Top | 2 | Only the top side of the ToolStripStatusLabel has borders. |
First, we declare above said Enumeration type as a class member. This member will represent the side in which the user wants to apply the border style. We set the default value as
None
. This means no border (refer the table above).
1 2 |
//Status 003: Used for the Borderside property ToolStripStatusLabelBorderSides applyto = ToolStripStatusLabelBorderSides.None ; |
6.2 Border Style Radio Buttons
When the user selects the Border Style using either ‘Sunken outer’ or ‘Etched’ radio buttons, we are making a call to the user-defined function ‘ApplyBorderStyle’. Note, we wrote event handler for one radio button only. Since the event is ‘checked-changed’, C# will call this when a user changes the check state of these radio buttons. Code is below:
1 2 3 4 5 |
//Status 005: Once we have the border sides, we can apply the border styple private void radSunken_CheckedChanged(object sender, EventArgs e) { ApplyBorderStyle(); } |
6.3 BorderSides and BorderStyle Properties
In the ApplyBorderStyle function, we set the
BorderSides
property to all three status slots. The
applyto
variable will hold the edges that requires border decoration. The checkbox event handler (not yet written) will assign or revoke the sides from this variable. After setting the
BorderSides
property, we apply the border style to all three status slots by setting the
BorderStyle
property. Note, the
Border3DStyle
enumeration supplies the border style to this property. Finally, we update the status slot 2 to inform the current border style to the user.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
private void ApplyBorderStyle() { SLabel1.BorderSides = applyto; SLabel2.BorderSides = applyto; SLabel3.BorderSides = applyto; if (radSunken.Checked == true) { SLabel1.BorderStyle = Border3DStyle.SunkenOuter; SLabel2.BorderStyle = Border3DStyle.SunkenOuter; SLabel3.BorderStyle = Border3DStyle.SunkenOuter; SLabel2.Text = "Sunken Outer"; } else { SLabel1.BorderStyle = Border3DStyle.Etched; SLabel2.BorderStyle = Border3DStyle.Etched; SLabel3.BorderStyle = Border3DStyle.Etched; SLabel2.Text = "Etched"; } } |
6.4 Apply And Revoke Border Style
To apply or revoke the sides in effect, we use the
bitwise OR(|)
,
bitwise XOR(^)
. The below example shows how these operators are used to apply or revoke Border Style from the top edge of Status Slots:
To apply to top side:
1 |
applyto = applyto | ToolStripStatusLabelBorderSides.Top; |
To revoke from top side:
applyto = applyto ^ ToolStripStatusLabelBorderSides.Top;
We use the above bitwise operations when our users check and uncheck the controls under the ‘Apply To’ group box. These check boxes specify the edges in which we will apply the border style. Below are the border sides, which is taken from the
ToolStripStatusLabelBorderSides
enumeration:
1 2 3 4 5 6 7 8 |
{ None = 0, Left = 1, Top = 2, Right = 4, Bottom = 8, All = 15, } |
The above two statement that applies and then revokes Border Style on the Top border side is depicted as follows:

Bit-wise Operation To Apply C# StatusStrip Border Style
The checkbox event handler will apply and revoke the corresponding edges using the method pointed out above. Note, after storing the required sides in the variable ‘
applyto
’, we make a call to the ‘
ApplyBorderStyle()
’. We already saw that the called function will apply user selected border styles to the applicable edges. The code for that is below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
//Status 004: Store the bordersides for applying the border style private void chkTop_CheckedChanged(object sender, EventArgs e) { //Apply the side using bitwise Or Operator. Remove the style using the Xor if( chkTop.Checked == true ) applyto = applyto | ToolStripStatusLabelBorderSides.Top; else applyto = applyto ^ ToolStripStatusLabelBorderSides.Top; ApplyBorderStyle(); } private void chkLeft_CheckedChanged(object sender, EventArgs e) { if (chkLeft.Checked == true) applyto = applyto | ToolStripStatusLabelBorderSides.Left; else applyto = applyto ^ ToolStripStatusLabelBorderSides.Left; ApplyBorderStyle(); } private void chkAll4_CheckedChanged(object sender, EventArgs e) { if (chkAll4.Checked == true) { chkTop.Checked = true; chkLeft.Checked = true; applyto = applyto | ToolStripStatusLabelBorderSides.All; } else { chkTop.Checked = false; chkLeft.Checked = false; applyto = ToolStripStatusLabelBorderSides.None; } ApplyBorderStyle(); } |
Below is the video that shows testing the Border style code explained above:
7. RenderMode Property of StatusStrip
The Render Mode is just a different style for the status bar. With the current background of the status bar, the Render Mode has a very little effect. Below is the code that makes use of the ‘
RenderMode
Property’:
1 2 3 4 5 6 7 8 9 10 11 12 |
//Status 008: Set different Render Mode private void radRModeSystem_CheckedChanged(object sender, EventArgs e) { if (radRModeSystem.Checked == true ) statusSt.RenderMode = ToolStripRenderMode.System; } private void radRModeProf_CheckedChanged(object sender, EventArgs e) { if(radRModeProf.Checked == true ) statusSt.RenderMode = ToolStripRenderMode.Professional ; } |
8. Spawn Status Slot Through Spring Property
As the name suggests, it performs the spring action on the status slots. When the ‘
Spring Property
’ is set to true for a slot, it expands to occupy the remaining free area in the status bar. When more than one slot has
Spring
property set to true, they share the remaining free space on the StatusStrip together.
Below is the checkbox handler code for setting the spring property for either first slot or second slot or for both. We intentionally do not provide this option for the third slot so that we can know how the third slot always fit the text it is holding.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
//Status 007: Set the Spring effect for status bar private void chkSpringLb1_CheckedChanged(object sender, EventArgs e) { if (chkSpringLb1.Checked == true) SLabel1.Spring = true; else SLabel1.Spring = false; } private void chkSpringLb2_CheckedChanged(object sender, EventArgs e) { if (chkSpringLb2.Checked == true) SLabel2.Spring = true; else SLabel2.Spring = false; } |
The below video shows how the Spring Property expands the Status Slot in Status Strip:
The sample is in VS2005 format. If you have the latest one, just accept the conversion asked by the dialog of your latest IDE.
Download Link From Google Drive: C# StatusStrip Control Example
Categories: C#
Tags: Border3DStyle, BorderSides, BorderStyle, RenderMode, Spring Property, ToolStripStatusLabelBorderSides