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

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

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

Another solution that seems to work consistently is to set the containing StatusStrip'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;
}

   

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.