Author Topic: How can I clear a TDateEdit box?  (Read 237 times)


  • New Member
  • *
  • Posts: 24
How can I clear a TDateEdit box?
« on: October 21, 2020, 07:24:57 pm »
I want a 'from date' (say, dt) to be able to become empty (implying 'from the beginning of time') rather than set to a very old date.

I have turned off the default today.

Although it works on startup, once I set a date I cannot get it to clear again.  I tried with dt.Clear or dt.Text := ''

Nothing works.  The moment I leave the box, the last used date is automatically filled in.  There is no OnLeave event, but it acts as if there is.

If I clear the field, close the form, and re-enter (because on entry I set the focus to a different field), it remains clear.

EDIT: Another workaround is to first set the focus to another field, then clear the TDateEdit.  So, problem overcome but it's still unclear why it does not work.  Could it be a bug in the control?

Any ideas?  Thanks.
« Last Edit: October 21, 2020, 11:45:34 pm by tonyp »


  • Hero Member
  • *****
  • Posts: 4041
Re: How can I clear a TDateEdit box?
« Reply #1 on: October 21, 2020, 11:52:33 pm »
mydateTime.Date := 0;

The only true wisdom is knowing you know nothing


TinyPortal © 2005-2018