StatusStrip label not visible when text too long
You can create a custom renderer based on ToolStripProfessionalRenderer
and override OnRenderItemText
method and draw text with ellipsis:
public class CustomRenderer : ToolStripProfessionalRenderer
{
protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
{
if (e.Item is ToolStripStatusLabel)
TextRenderer.DrawText(e.Graphics, e.Text, e.TextFont,
e.TextRectangle, e.TextColor, Color.Transparent,
e.TextFormat | TextFormatFlags.EndEllipsis);
else
base.OnRenderItemText(e);
}
}
Then it's enough to set Renderer
of your StatusStrip
to your custom renderer:
this.statusStrip1.Renderer = new CustomRenderer();
In below example, You can see the behavior of a ToolStripStatusLabel
which it's Spring
property is set to true
and its StatusStrip
uses CustomRenderer
:
On Visual Studio 2017, the accepted answer didn't work for me. So here is another simple solution.
Set LayoutStyle
property of StatusStrip to Flow
. i.e:
statusStrip1.LayoutStyle= LayoutStyle.Flow;
And Set
`statusStrip1.AutoSize= false;`
If you set
ToolStripStatusLabel.Spring = True;
then you won't get the "..." but the text will be shown even when the available space is insufficient.