Using StatusStrip In Windows Forms

Introduction

In this article, I am going to explain how to use a StatusStrip in a Windows Forms app using Visual Studio 2017.

Step 1. Start the Project

Let's create a new project using Visual Studio 2017.

Select New Project--->Visual C#-->Windows Forms App (.NET Framework), give your project a name and click OK.

Windows Forms App

This action creates a WinForms project with a default form and you should see the Windows designer.

Step 2. Drag and Drop Control

Let's add a StatusStrip control to the form by dragging it from Toolbox and dropping it into the form. You will see a StatusStrip 1 is added to the form. This control is now available to you in the code behind.

Toolbox

StatusStrip Control

StatusStrip control displays Windows status. It is usually at the bottom of a window. We use a ToolStrip hyperlink in the C# windows forms Status Bar.

ToolStrip

StatusStrip replaces and extends the Status Bar control of the previous version. StatusStrip control displays information about an object being viewed on a form, the object components or contextual information that relates to that object's operation within the application.

Typically, a StatusStrip consists of ToolStrip objects, but by default, StatusStrip has no panels. ToolStrip control is capable of hosting Button, Label, SplitButton, DropDownButton, Separator, ComboBox, TextBox, and ProgressBar controls.

Now, let's add another control to the form by dragging a control from the Toolbox to the form. You may also want to change the properties of the other controls.

Properties

Let's add a Label, Button, and Textbox control to the form. Change the text of the button and Label controls to what you like.

Step 3. Coding

Follow the coding given below,

private void textBox1_MouseHover(object sender, EventArgs e) { 
    toolStripStatusLabel1.Text = "Enter User Name"; 
}

private void textBox1_MouseLeave(object sender, EventArgs e) { 
    toolStripStatusLabel1.Text = ""; 
}

private void textBox2_MouseHover(object sender, EventArgs e) { 
    toolStripStatusLabel1.Text = "Enter Password with minimum one character"; 
}

private void button1_MouseHover(object sender, EventArgs e) { 
    toolStripStatusLabel1.Text = "Click here to Login"; 
}

Step 4. Compile and Run

Now simply compile and run the application.

Once you place the cursor on the Textbox and Button, the corresponding text belonging to that will be displayed on the Status Bar.

 Textbox

Corresponding text

Status Bar

Summary

In this basic article, you saw how to use a StatusStrip control. Hope you found this article interesting. For any feedback, please post it as comments at the bottom of this article.

Thank you!


Similar Articles