1. Home
  2. Computing & Technology
  3. Delphi Programming

How to make a TDateTimePicker display blank

By , About.com Guide

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') ;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» How to add a button to the IE Toolbar?
« Change the default directory Delphi uses to save projects

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2002 Delphi Tips
  7. How to make a TDateTimePicker display blank

©2009 About.com, a part of The New York Times Company.

All rights reserved.