Make a StatusLabel display its text even if it doesn’t fit in C#


If the text displayed in a StatusLabel is too long to fit in the containing StatusStrip control, then by default the StatusLabel doesn’t display anything. I don’t know what the rationale behind that it is, but it makes the StatusLabel somewhat pointless.

I’ve seen people claim that setting the StatusLabel control’s Spring property to true will make it display properly. That doesn’t seem to work for me, at least in some versions of Visual Studio. It could depend on the version.

Another solution that seems to work consistently is to set the containing StatusStrip control’s LayoutStyle property to Flow instead of the default value Table. That makes the StatusLabel display as much of its text as will fit.

private void Form1_Load(object sender, EventArgs e)
    lblStatus.Text = "This text is much too long to fit in the " +
        "form when it is its normal size.";
    statusStrip1.LayoutStyle = ToolStripLayoutStyle.Flow;

That’s all there is to it.

Download Example   Follow me on Twitter   RSS feed   Donate

This entry was posted in controls, user interface and tagged , , , , , , , , , , , , . Bookmark the permalink.