[C# 2.0] CustomControl and DrawString (GDI+)

M

Martin

Hello All,

I've created a WinForm control and everything is OK except the look
of the font on my control.

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);

e.Graphics.SmoothingMode = SmoothingMode.HighQuality;

SizeF objTextSize = e.Graphics.MeasureString(this.Text,
this.Font);
PointF objTextPosition = new PointF(0, (this.Height -
objTextSize.Height) / 2);

e.Graphics.DrawString(this.Text, this.Font, Brushes.Black,
objTextPosition);
}
}

If I compare my Control to a Label, the text in the Label looks a lot
more sharp, beautiful, clean and clear... Why? For the same font and
size, I should have the same look. No?

What is wrong with my DrawString? Why my control text and font
doesn't have the same look and feel as a Label text and font?

Thanks for you help!

Martin
 
?

=?ISO-8859-2?Q?Marcin_Grz=EAbski?=

Hi Martin,

Did you test different settings of:

Graphics.TextContrast
or
Graphics.TextRenderingHint

with regards
Marcin

Martin napisa³(a):
 
M

Martin

I'll give this a try !

Thanks !

Marcin said:
Hi Martin,

Did you test different settings of:

Graphics.TextContrast
or
Graphics.TextRenderingHint

with regards
Marcin

Martin napisa³(a):
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top