Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update StatusStrip in Windows Forms

People also ask

What is StatusStrip C#?

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.

How do you refresh a Windows form in C#?

You can use the Form. Invalidate(); or Form. Refresh(); methods.

What is status strip?

A StatusStrip control displays information about an object being viewed on a Form, the object's components, or contextual information that relates to that object's operation within your application. Typically, a StatusStrip control consists of ToolStripStatusLabel objects, each of which displays text, an icon, or both.


enter image description here

You will need to add a ToolStripStatusLabel to the StatusStrip.

Then set the text of the label instead (you need to do a statusstrip.Refresh as there is no refresh on the status-label).

The Text property on the StatusStrip comes from the StatusStrip inherits ToolStrip (which in turn inherits Control), but has no visual effect due to the nature of ToolStrips. It can be a bit confusing.

Example:

private void textBox1_TextChanged(object sender, EventArgs e)
{
    //...
    lines = Regex.Split(textBox1.Text.Trim(), "\r\n");
    lineCount = lines.Count();

    //this label is added in visual editor using the default name
    ToolStripStatusLabel1.Text = string.Format("Lines: {0}", lineCount);
    StatusStrip1.Refresh();
}