Board index » delphi » Edit Format vs. Display Format for DBEdit

Edit Format vs. Display Format for DBEdit

I have a small DB that uses a DBEdit control and TDateField to display
a date from the DB.  I have set the DisplayFormat of the TDateField
to:
    mmmm d, yyyy

This displays the date exactly as I want (i.e., Februrary 8, 1996).
However, when I click on the DBEdit control to change the date, it
uses a completely different date format (i.e., 2/8/96).

How can I make the edit format the same as the display format?

Thanks for any help.

**************************************************************************
* Ken Carpenter                 * "Stop your foul whining you {*word*127}     *
* Software Design & Development *  piece of distended rectum!"           *
* Network Group                 *    -- A.J. Rimmer to A.J. Rimmer       *
* Delta Controls Inc.           *       Aboard the mining ship Red Dwarf *
**************************************************************************

 

Re:Edit Format vs. Display Format for DBEdit


Quote
kcarp...@mindlink.bc.ca (Ken Carpenter) wrote:
>I have a small DB that uses a DBEdit control and TDateField to display
>a date from the DB.  I have set the DisplayFormat of the TDateField
>to:
>    mmmm d, yyyy
>This displays the date exactly as I want (i.e., Februrary 8, 1996).
>However, when I click on the DBEdit control to change the date, it
>uses a completely different date format (i.e., 2/8/96).
>How can I make the edit format the same as the display format?

The good news is that it can be done.
The bad news is that it means writing your own TDBEdit type
components.  Even if you didn't buy the VCL source code your Delphi
came with the source code for DBCTRLS.PAS (or something like that) in
the \DELPHI\DOC directory.  You will find the source code there.  If
you look at it you will find TDBEdit explicitly formats data depending
on the type of the field, when the control does NOT have the focus.
Otherwise the data is a normal editable plain string.  You will have
to modify this behaviour.

Or buy a third party component, much easier if you don't write many
components.

You might be able to do this with the Edit-mask property of the fields
(get to them by double clicking the TTable and adding all the fields.
Then select a field and look in the Object Inspector).  However I gave
up on that technique as Borland's edit mask implementation is
pathetic.
--
Tim Shea
CSI
c...@citysoft.com

Other Threads