Page 1 of 1

DTPicker without forced date formatting

Posted: Thu Oct 16, 2008 9:50 pm
by PatrickWeisser
Hello Everyone,

I really like the DTPicker control, but in my application I allow dates to be entered without formatting (as a simple string with a TGet()). I have validation code which normalizes the date string and tells the user if there is a problem with the date when focus is shifted away. This is the way QuickBooks handles dates, and allows for quick entry without getting "hung up" on the slashes. For example you could enter:

1 2 6

...for January 2, 2006 with or without the slashes. And since the whole date string is highlighted when the control receives focus, blanking out a date is as simple as pressing the space bar and the tab key.

Does anyone know a way to turn off the date validation and slash (/) formatting in a TDatePick object, while keeping the pop-up calendar functionality?

Thanks!

-Patrick

Posted: Fri Oct 17, 2008 3:36 am
by James Bott
Patrick,

I think you would have to call the dtpicker control from another button. The dtpicker is returning a value in date format so you then have to convert it to string to place it in your GET.

James

Posted: Fri Oct 17, 2008 3:48 am
by ShumingWang
The better ,Datepicker intergrate into Tget class action clause,if this work could done by FWH .
Shuming Wang

Posted: Fri Oct 17, 2008 5:34 am
by PatrickWeisser
Thanks James. I think what I might try doing is to size the DTPicker control down so that only the down-arrow shows to activate the calendar, and I will place it right next to the text control I'll be using for the date string. If the user types a date, the VALID clause in the text control will do my custom validation to normalize and validate the string, then call the SetDate() method of the DTPicker control to update it with the CtoD() of the text control. Likewise, if the user clicks on the DTPicker down-arrow and selects a date, I will have a code block set for the "On Change" clause of the DTPicker control that will set my text control to the DtoC() of what's in the DTPicker control.

Posted: Fri Oct 17, 2008 5:32 pm
by James Bott
Patrick,

Sounds like a good solution. Let us know how it works out.

I am a big fan of allowing data input like you are doing, and post processing it into the proper format. Anything to make life easier for the user.

Other date tricks I have tried are "t" for tommorow, "w" for one week from today, "m" for one month from today, "9d" for 9 days from today, etc. There are all kinds of shortcuts you can provide.

Regards,
James