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:
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?
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? :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With