Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Label and TextBox: same font looks different

I have Label and TextBox in Windows Forms, C#, .NET.

I can see a strange behaviour: I set the same Font to Label and TextBox, and the same word looks different there:

Word "_DATEU" looks almost like bold in label

The Font is Tahoma, 10.25pt. As you can see, on the top is a Label, and it looks like if it had Bold style comparing to TextBox. Why does this happen? Can I make my TextBox and Label look the same with this font?

like image 840
Artem Kachanovskyi Avatar asked Nov 01 '22 17:11

Artem Kachanovskyi


1 Answers

This is caused by floating precision, it would appear that labels choose to round up whilst textboxes round down to the nearest whole number (integer).

Its possible that WPF can get around this since it uses DirectX to handle its drawing. Since winforms uses GDI there isn't a lot of support for floating precision within drawing.

You may be better off just using 10pt since there isn't a lot of different between this and 10.25... You are using it anyway for your textbox right? :)

like image 90
Sayse Avatar answered Nov 09 '22 13:11

Sayse