5

I'm using a DateTimePicker in my Windows Forms app with a custom format: dd/MM/yyyy.

The first digit is partially cut off when using the Segoe UI Light font as shown:

First number cut off

Adding spaces/symbols to the custom format (i.e. " dd/MM/yyyy") doesn't fix the problem. It only happens with Segoe UI Light (Segoe UI Regular is fine).

Apart from changing the font, how can I stop the first number from being cut off?

I'm using Visual Studio 2017, and the target .NET framework is 4.7.2.

Edit: Interestingly, if the custom format is set to MM/dd/yyyy, the first digit of the day is cut off: Image

Lews Therin
  • 3,707
  • 2
  • 27
  • 53
  • 1
    try to set Horizontal Alignment to center if it is set to left – apomene Mar 21 '19 at 14:11
  • 1
    I can't reproduce it with the font set to `Segoe UI Light, 10pt` or any other size. Perhaps there's another attribute somewhere? Looks like an oversight in the control, as it is immediately noticable if you change the font to italic. I can't think of a solution other than overwriting it or adding in a space – NibblyPig Mar 21 '19 at 14:14
  • 2
    Actually, tried that and it's even weirder if you set it to dd2/MM/yyyy then the second digit is cut off (when italic). That is super weird. I'm gonna say it's a bug in the control and there's no workaround unless you want to override the paint method and draw it yourself. – NibblyPig Mar 21 '19 at 14:19
  • @NibblyPig For me, italic is fine but light is broken; I might just have to switch fonts. apomene: I can't seem to find the horizontal alignment property or anything similar for the DateTimePicker anywhere. –  Mar 21 '19 at 14:34
  • 1
    There is no HorizontalAlignment on a Winforms DateTimePicker. However I am unable to reproduce the problem. Do you have some other configuration on the picker? Did you change the font at the Form level or just for that control? – Steve Mar 21 '19 at 15:17
  • If you set a font with specific weight, then reopen the font selection interface and you see that the selected Font is not selected anymore (you have to re-select it), then the Font is not exactly supported. Choose another weight. `SemiLight` should be fine. – Jimi Mar 21 '19 at 16:24
  • @Steve I've played around with it a bit more. If the day contains a 1 then it won't get cut off (21 and 31 will work fine while 22, 23 etc. will not). I think I might just use another font. –  Mar 21 '19 at 23:04

1 Answers1

0

Increase or decrease date picker font size. Set integer value in font size.

Ayush
  • 1