[C# Helper]
Index Books FAQ Contact About Rod
[Beginning Database Design Solutions, Second Edition]

[Beginning Software Engineering, Second Edition]

[Essential Algorithms, Second Edition]

[The Modern C# Challenge]

[WPF 3d, Three-Dimensional Graphics with WPF and C#]

[The C# Helper Top 100]

[Interview Puzzles Dissected]

[C# 24-Hour Trainer]

[C# 5.0 Programmer's Reference]

[MCSD Certification Toolkit (Exam 70-483): Programming in C#]

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

[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 the example to experiment with it and to see additional details.

© 2009-2023 Rocky Mountain Computer Consulting, Inc. All rights reserved.