HomeSearch

C# StatusStrip Example: Windows Forms

Learn about the StatusStrip control in Windows Forms. Add a StatusStrip in Visual Studio.

StatusStrip. A StatusStrip displays window status. It is usually at the bottom of a window. We use a ToolStripStatusLabel hyperlink in the C# Windows Forms status bar.

Intro. We see an example of StatusStrip in Windows Forms, with tips on how to use its properties. We introduce some parts of the Windows Forms program.

Some notes. There are other controls such as LinkLabel that you can use for links. But this article is about my favorite way, the hyperlink in the status bar.LinkLabel

Add control. The StatusStrip is a control in your Toolbox in Visual Studio. Double click on its icon and then it will appear in the tray at the bottom of the Visual Studio window.

Items: Select the status strip control on your form, and in the Properties pane look through the entries there and select Items.

Labels: In the Items window you can add things to the StatusStrip. Add new ToolStripStatusLabels and a hyperlink.

Steps. I will assume you already have a StatusStrip. There are a few important things. All of the items will be squished to the left of the status strip by default.

And: We can change this, and right-align a label. Here are the steps required to configure the StatusStrip.

Spring: To right-align things on a StatusStrip we add a "spring" in between the left and right items.

First step. Please open the Items dialog in Visual Studio. On your StatusStrip, open the Items Collection Editor dialog in the A-Z listing.

Tip: The Items Collection Editor dialog is pictured in the screenshot here. It will look different in your version of Visual Studio.

Second, add some items. Leave the Status Label dropdown selected and click on the big Add button. You can also add other types of controls to your status strip here.

Tip: To add a hyperlink, you can use a regular status label. You can make it a hyperlink later.

Third, add a ToolStripStatusLabel with "Spring" set to true. Put it after the leftmost (first) status item. Add another status label after it. This will right-align the third status label.

Finally: On the right side of the Items Collection Editor dialog, you will see another grid list.

Then: Scroll to Text and type in the text of your link. Set the IsLink property to true.

Hyperlink. Double-click on the ToolStripStatusLabel you want to turn into a hyperlink. We must use the Click event handler to make the status item do something when it is clicked.

Process: To start a web browser, we will need to use the Process.Start method in System.Diagnostics.

Process

Tip: In the new Click event handler, add the inner line here. You can directly access System.Diagnostics.

Implementation of Click event handler: C# private void toolStripStatusLabel3_Click(object sender, EventArgs e) { // Launch Dot Net Perls website. // ... You should change the URL! System.Diagnostics.Process.Start("http://www.dotnetperls.com/"); }

A summary. We added a StatusStrip. We used the example of a right-aligned hyperlink to show how the system works. A simple hyperlink in the status bar is good for branding.
Home
Dot Net Perls
© 2007-2020 Sam Allen. Every person is special and unique. Send bug reports to info@dotnetperls.com.