Lazarus

Programming => General => Topic started by: tonyp on October 21, 2020, 07:24:57 pm

Title: How can I clear a TDateEdit box?
Post by: tonyp 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.
Title: Re: How can I clear a TDateEdit box?
Post by: jamie on October 21, 2020, 11:52:33 pm
mydateTime.Date := 0;

TinyPortal © 2005-2018