Search code examples
delphidelphi-2010

Show "empty" TDateTimePicker


How can I show an "empty" TDateTimePicker in Delphi 2010 (that is, hide the display of the date so the control appears empty). I know about the trick of setting the format to show the epoch, but with Delphi 2010 running on Windows 7 the string "A.D." appears in the control when I do this.


Solution

  • try setting the format to a blank space Value.

    DateTimePicker1.Format:=' ';
    

    and then in the OnChange method set the format again

    procedure TForm1.DateTimePicker1Change(Sender: TObject);
    begin
    DateTimePicker1.Format:=ShortDateFormat;
    end;