I have a custom Label class, drawn text is not suitable. What am I doing wrong here?
class MyLabel: Label { public MyLabel() { SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true); } protected override void OnPaint(PaintEventArgs e) { using (LinearGradientBrush brush = new LinearGradientBrush(ClientRectangle, Color.Black, Color.LightGray, LinearGradientMode.ForwardDiagonal)) e.Graphics.DrawString(Text, Font, brush, ClientRectangle); } }
If I set the MyLabel text as "123456790 123456790" ( AutoSize = true ), then I see in Designer (or at runtime) "1234567890 123456789" (without the last zero, but some space). If I try "1234567890 1234567890 1234567890 1234567890", then there will be "1234567890 1234567890 1234567890 12345678" (no "90", but again some space).
c # winforms labels ownerdrawn
Sinatr
source share