TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

StatusStrip Example in Windows Forms

This C# article focuses on the StatusStrip control in Windows Forms.

StatusStrip. A StatusStrip displays window status.

We use a ToolStripStatusLabel hyperlink in the C# Windows Forms status bar. We see an example of StatusStrip in Windows Forms, with tips on how to use its properties.

Intro. We introduce some parts of the Windows Forms program. 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.

StatusStrip. 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.

Status Items collection. Select the status strip control on your form, and in the Properties pane look through the entries there and select Items. There you can add new ToolStripStatusLabels and a hyperlink.

Steps. I will assume you already have a StatusStrip. There are a few really important things you need to know. First, 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.

First, open the Items dialog in Visual Studio. On your StatusStrip, open the Items Collection Editor dialog in the A-Z listing. The Items dialog is pictured in the screenshot here.

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. To add a hyperlink, you can use a regular status label.

Third, add Spring item. Add a ToolStripStatusLabel with the Spring property 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. To start a web browser, we will need to use the Process.Start method.

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("");
}

 

Summary. I provided some quick steps on dealing with StatusStrip controls. I 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. It won't scare people off.


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf