In my project I need to create some label at runtime. These have a different height that depends from a field of a database. I need to write some text in the label, but I need, if the label have a small height, to resize the font depending by the label height.
I’ve tried with this:
Label lbl = new Label();
lbl.AutoSize = false;
lbl.Font = new System.Drawing.Font(lbl.Font.FontFamily, Convert.ToSingle(lbl.Height / 2));
lbl.TextAlign = ContentAlignment.MiddleCenter;
You can use the FontHeight property to change the height of a font. This could do the job.
MSDN: