As far as I know it is not possible to use different fonts for
different parts of the same label, since it doesn't support anything
like RTF markups or the like.
So either you use two labels (one for the bold part, one for the
other) or you derive your own label class from label and handle the
drawing yourself.
I guess personally I would go with deriving in this case, since the
implementation would consist mostly of pretty basic GDI+ stuff and is
more flexible than always creating two labels.
hth,
Kevin Wienhold- Hide quoted text -
- Show quoted text -
Okay, thanks
I have overrided the OnPaint() method
For single line text a code would be something like this
// show first 10 letters in bold
e.Graphics.DrawString(this.Text.Substring(0,9),
new System.Drawing.Font("Tahoma", 8.0F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((byte) 0)),
new SolidBrush(this.ForeColor), new
Rectangle(this.Padding.Left, this.Padding.Top, this.Width -
this.Padding.Left, this.Height), StringFormat.GenericDefault);
Size sz = new Size(this.ClientSize.Width, Int32.MaxValue);
sz = TextRenderer.MeasureText(this.Text.Substring(0, 9), this.Font,
sz, TextFormatFlags.WordBreak);
e.Graphics.DrawString(this.Text.Substring(10),
new System.Drawing.Font("Tahoma", 8.0F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((byte)0)),
new SolidBrush(this.ForeColor),
this.Padding.Left + sz.Width, this.Padding.Top);