How to change spaces between lines in winforms shortcut?

I have a label with unknown text. the text contains \ n. I want more space between \ n lines. How can i install it?

+2
source share
1 answer

You can create a custom component of the shortcut and redefine its measurement and drawing, here you can find a fragment of the paint method that implements line spacing.

Edit: adding a fragment here if the link is dead:

string text = "Sri Lanka";
Graphics g = e.Graphics;
Font font = new Font("Arial", 10);
Brush brush = new SolidBrush(Color.Black);
float lineSpacing = 0.5f;

SizeF size = g.MeasureString("A", font);

float pos = 0.0f;
for ( int i = 0; i < text.Length; ++i )
{
    string charToDraw = new string(textIdea, 1);
    g.DrawString(charToDraw, font, brush, pos, 0.0f);
    SizeF sizeChar = g.MeasureString(charToDraw, font);
    pos +=  sizeChar.Width + size.Width * lineSpacing;
}
+3
source

All Articles