Board index » delphi » TDBEdit and masking

TDBEdit and masking

I'm using a DBEdit component to view and edit a
database.  There are phone-number and zip-code
fields that I would like to mask, but can't figure
out how to do it.

There seems to be an 'IsMasked' property, but I
don't know how to actually create the mask.

Kenny Hunt

 

Re:TDBEdit and masking


Kenny A. Hunt (h...@bolivar.cs.uiowa.edu) wrote:
: I'm using a DBEdit component to view and edit a
: database.  There are phone-number and zip-code
: fields that I would like to mask, but can't figure
: out how to do it.

: There seems to be an 'IsMasked' property, but I
: don't know how to actually create the mask.

The TMaskEdit component is provided for use with data values not directly
connected to a field in a table. To provide a mask template for field
values displayed/edited through a data-aware control, such as a TDBEdit,
you will need to set the EditMask property at the TField level. For inst-
ance, for a field called Phone in Table1, where a TField has been created,
the syntax would be:

  Table1Phone.EditMask := '!\(999\)000-0000;1;_';

The editing mask !\(999\)000-0000;1;_ is stored into the EditMask prop-
erty as a String. If no TField was created, you can use the Fields property
or the FieldByName method to address the field and its EditMask property:

  Table1.FieldByName('PHONE').EditMask := '!\(999\)000-0000;1;_';

--
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/ Steve Koterski               _/   The opinions expressed here are    _/
_/ koter...@borland.com         _/         exclusively my own           _/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

Re:TDBEdit and masking


Quote
>The TMaskEdit component is provided for use with data values not directly
>connected to a field in a table. To provide a mask template for field
>values displayed/edited through a data-aware control, such as a TDBEdit,
>you will need to set the EditMask property at the TField level. For inst-
>ance, for a field called Phone in Table1, where a TField has been
created,
>the syntax would be:
>  Table1Phone.EditMask := '!\(999\)000-0000;1;_';

I too have difficulty with this, thus...

The above works fine for sting type fields as telephone numbers, but what
about currency and other number formats.  I have tired and tried and can
only format these by attaching a database to the form.  For simple dialogs
this is a waste.

Any suggestions???

By the way, there is a simple "MASK" component added as a "speed" button
under "additional"

Other Threads