I’m very new to using Winforms so five me if this is a silly question, but I’ve been having some difficulty and I figured maybe someone with more experience would be able to answer this for me.
I’ve seen that there are lots of answers out there dealing with changing the background color of a DateTimePicker control, usually by creating a custom DateTimePicker, filling a rectangle of the desired background color, and then drawing the text over that.
However, when using the default DateTimePicker for just selecting time, the user can click the different sections of the time (which then highlights that section) and the user can then use the up/down arrows to alter that specific section. For example, if the format is HH:mm tt, then the time in the control could say 12:00 AM. Each section (hours, minutes, am/pm) can be edited individually by the user. The user could click on the “12”, and the “12” would be highlighted to show the user that that section is what will be changed if the up/down arrows are used.
This becomes a problem when using the popular custom DateTimePicker that redraws the text over the filled rectangle, because the redrawn text does not implement this section highligting and now the user has no way to tell what section of the time is being edited before using the up/down arrows. Also, depending on the font size, positioning, etc, the newly drawn text doesn’t always line up nicely with the “selection areas”, which makes it even more difficult to change the control to the desired time.
Long story short, is there any way to change the background of a DateTimePicker control without losing the default text selection highlight that comes with choosing a time using the up/down arrows?