Главная страница | назад





Article #28214: How to make the TDateTimePicker display blank.

Question:

How do I make the TDateTimePicker display blank?

Answer:

A little trick is to use the letters gg in the format property. This format pattern displays the period or era. This pattern is ignored if the date to be formatted does not have an associated period or era string — which TDateTimePicker does not — thus the display is blank. When a date is subsequently selected you can then set the format to '' in the OnChange or OnClick event handler in order to get it to display again.

The format property was added in Delphi 6. In earler versions add CommCtrl to the uses clause of your unit and use the following code:

DateTime_SetFormat(DateTimePicker1.Handle, 'gg');

Last Modified: 09-JAN-02