TDateTimePicker error - ShowCheckBox mode

I have a TDateTimePicker set to "Time" mode.

I have noticed when scrolling through the numbers, sometimes I will get an error message:

Project ... raised exception class EDateTimeError with message 'You must be in ShowCheckbox mode to set this date'.

Now, I noticed that in the Properites for the TDateTimePicker there IS a property called "ShowCheckbox" and it WAS set to false.

Now, I can try setting this to true and see if the error goes away, but what I don't understand is what this error has to do with me scrolling throught e hours or minutes in a TDateTimePicker.



I am "points poor" so I can only offer 10 points
Tom KnowltonWeb developerAsked:
Who is Participating?
ondertolConnect With a Mentor Commented:
Probably you set the property "Time" of your TDateTimePicker to not valid value.
If you set the Time value on this mode:

DateTimePicker1.Time := MyTime;

you must control MyTime, probably is not valid Time format.
Create MyTime as:

  MyTime : TDateTime

and you must use the instruction EncodeTime (or StrToTime) to set your time:

  MyTime := EncodeTime(10,07,01,5);  

--- or ----

  MyTime := EncodeTime(myHour,MyMin,MySec,myMSec);

--- or ---
  MyTime := StrToTime('11.33.44');


!!!remember: the hours are calculated on 24 hours for day

If you want the current time write: "MyTime := Time" or "MyTime := Now";
Tom KnowltonWeb developerAuthor Commented:
Looks like the string came from

Delphi4\Source\Vcl\Comstrs.pas :

  sNeedAllowNone = 'You must be in ShowCheckbox mode to set to this date';
Tom KnowltonWeb developerAuthor Commented:
Thank you
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.