Re: clear Delphi Datetimepicker while loading

Posted by webmaster Guido on February 07, 2005

In Reply to: Want to clear Datetimepicker while loading posted by Venkat on January 05, 2005

: I am using Datetimepicker control in our application, but it is displaying system current by default.

: Please let me know how to clear Datetimepicker control while loding the form.

Delphi's DateTimePicker has Date and Time properties; by default, these are set to the system's date and time at the moment that you add the component to a form.

You can't clear these properties to *nothing* in the Object Inspector, they always will contain a value:
- clearing the Date property to an empty value, is the same as setting to 0, which means: the last day of 1899;
- clearing the Time property to an empty value, results in setting it to 0, which means: 00:00:00.

However, you can preset the Date and/or Time of the DateTimePicker at runtime, for example when the form is created:

procedure TForm1.FormCreate(Sender: TObject);
begin
  // set Date property to tomorrow
  DateTimePicker1.Date := Date + 1;
  // set Time property to 12 o'clock
  DateTimePicker1.Time := 0.5;
end;

[ Delphi Forum and Tutorials -- by DelphiLand ]