How to find padding space around the label text?
I am adding a label controls at run time. I can add or modify text in label and can change the font also.Now my problem is When i changed the font of text in label, alignment is not proper,its due to padding.Is there any way to find how much padding is ocured开发者_运维技巧 [ed: obscured?] based on font?
Did you look at the Padding
property?
You may have to turn off AutoSize
to get better results.
Couldn't you call TextRenderer.MeasureText
?
If you provide the correct target size (being the rectangle that the label can occupy), you should be able to find out how much space the text will occupy/has occupied.
精彩评论