Code: Select all
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.StatusStrip)]
public partial class SpringLabel : ToolStripStatusLabel
{
public SpringLabel()
{
this.Spring = true;
}
protected override void OnPaint(PaintEventArgs e)
{
var flags = TextFormatFlags.Left | TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter;
var bounds = new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height);
TextRenderer.DrawText(e.Graphics, this.Text, this.Font, bounds, this.ForeColor, flags);
}
}
Code: Select all
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.StatusStrip)]
public partial class SpringLabel : ToolStripStatusLabel
{
private string? _sltext;
public new string? Text
{
get => _sltext;
set { _sltext = value; ToolTipText = _sltext; Invalidate(); }
}
public SpringLabel()
{
this.Spring = true;
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
var flags = TextFormatFlags.Left | TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter;
var bounds = new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height);
TextRenderer.DrawText(e.Graphics, _sltext, this.Font, bounds, this.ForeColor, flags);
}
}
< /code>
Dies funktioniert gut, unterstützt aber wahrscheinlich einige Eigenschaften wie Bilder. Auch die übergeordnete StatusStrip -Steuerung scheint zu erfordern, dass das LayoutStyle