I have set standard VCL TDateTimePicker - MaxDate property to Date - e.g.
DTPicker.MaxDate := Date;
However, there is a problem. If I now set the date to be the current one:
DTPicker.Date := Date;
It will not accept it. The control simply stays at the date which is set at the design time. I can solve it by setting MaxDate to be Date + 1 and then setting the Date property works fine and shows today's date, but then user is able to select tomorrow's date. I also tried to set MaxDate to Date + 0.99999999 but that also is of no help.
I use Delphi 2010 and C++Builder 2010 (if this is a bug in either of them).
Any ideas how to prevent selecting any date beyond today and set the control date to today's date?
Changing the date results in - "Failed to set calendar date or time."
Update:
I managed to make it work as following:
- open drop-down in TDateTimePicker (during runtime) and intentionally select Today's date (click on already selected Today's date)
- after that select any past date
- click button which has the code to reset the date and then it works.
My solution will likely be to use range-check before closing the form, as it seems that MaxDate is useless, at least with this version of Delphi.