views:

558

answers:

2

I've set the MaxDate and MinDate properties of a DateTimePicker. However, when I test the control at runtime, there is no way to tell the invalid dates from the valid ones. The only difference is that clicking on an invalid date does nothing.

This is not very intuitive for the user. I want to be able to tell at a glance what the valid dates are.

Is there any way to highlight the valid date range - or more appropriately, 'dim' the invalid dates? Or, is there another control which would be more appropriate? I'm sure a couple of combo boxes would work, but I really think the user should be presented with a calendar control when asked for a date.

CONTEXT: This is a WinForms charting application. The range of valid data is fixed (new data is added via another process). The user needs to pick a date and time for the chart's start time (as well as a duration, which is handled separately).

A: 

Im not sure that there is without extending the control yourself, and owner drawing which would be an effort.

If you cant find the functionality your after, I would consider the use of an ErrorProvider control and validating the users input as an option.

Jim Burger
+1  A: 

I have a similar issue. I've extended the DateTimePicker control to run a validate process whenever the value changes and to either revert to the previous value or to the nearest legal value in the event of an illegal choice.

The logical extension to this is to flash up a warning dialog or label to inform the user that this has happened.

You could also override the calendar display portion of the control to highlight/lowlight the invalid options - it already highlights the current day and the current selection, for example.

Unsliced