Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TMaskEdit Questions


This question is answered.


Permlink Replies: 4 - Last Post: Feb 22, 2018 3:08 PM Last Post By: Earl Staley
Earl Staley

Posts: 99
Registered: 4/9/07
TMaskEdit Questions  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2018 5:11 PM
I have a MaskEdit control with the EditMask set for a date with the format: !99/99/0000;1;_

If the user begins to enter a date, and then changes his mind and erases all of the date characters, the following error occurs:
'Invalid input value. Use escape key to abandon changes'

1) How can I suppress that error and allow the program to proceed with the user's input data deleted? (I want either a valid date or no data from the MaskEdit.)

2) Is there a way to use the OnExit event to check each field (MM, DD, and YYYY) for valid data and then set the focus to the appropriate field for correction ‌when invalid data is found? (Example code would be appreciated.)

3) What is the meaning of the '!' character at the start of the EditMask?

Thank you...
Earl Staley
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TMaskEdit Questions
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2018 6:25 PM   in response to: Earl Staley in response to: Earl Staley
Earl Staley wrote:

I have a MaskEdit control with the EditMask set for a date with the
format: !99/99/0000;1;_

Why are you using a TMaskEdit and not a TDateTimePicker?

1) How can I suppress that error and allow the program to proceed
with the user's input data deleted?

Derive a new component from TMaskEdit and override the virtual
ValidateError() method.

2) Is there a way to use the OnExit event to check each field (MM,
DD, and YYYY) for valid data and then set the focus to the
appropriate field for correction when invalid data is found?

No. Better to switch to TDateTimePicker, which does not allow the user
to enter an illegal date/time to begin with.

3) What is the meaning of the '!' character at the start of the
EditMask?

http://docwiki.embarcadero.com/Libraries/en/System.MaskUtils.TEditMask

--
Remy Lebeau (TeamB)
Earl Staley

Posts: 99
Registered: 4/9/07
Re: TMaskEdit Questions  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2018 8:33 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Rent,

Thank you for your response.

The dates, if entered, are posted into a database. The user may not know the date. If I use a TDateTimePicker, I have no idea if the date in the TDateTimePicker is the date the user intended or just the date that was in the TDateTimePicker when the form was shown.

Is there a way to make the TDateTimePicker null or to make the TDateTimePicker date null if the user changes his mind about entering the date. I could put a TCheckBox on the form to indicate whether the user wants to use the date or not, but that doesn’t seem like a very elegant solution.

Earl
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TMaskEdit Questions  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 21, 2018 11:14 AM   in response to: Earl Staley in response to: Earl Staley
Earl Staley wrote:

Is there a way to make the TDateTimePicker null or to make the
TDateTimePicker date null if the user changes his mind about entering
the date.

TDateTimePicker has an option to display a checkbox. You can ignore
the date if the Checked property is false. If you later populate the
TDateTimePicker from a database value, you can set the Checked property
to true in code.

I could put a TCheckBox on the form to indicate whether the user wants
to use the date or not, but that doesn’t seem like a very elegant
solution.

TDateTimePicker has its own built-in checkbox.

--
Remy Lebeau (TeamB)
Earl Staley

Posts: 99
Registered: 4/9/07
Re: TMaskEdit Questions  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 22, 2018 3:08 PM   in response to: Earl Staley in response to: Earl Staley
Remy,

I got around the problem by changing the EditMask to: !99/99/9999;1;_

Then I handled all incorrect entries on the OnExit event.

Thank you for your help...
Earl Staley
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02