Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EDITMASK IN DBGRID DOESN'T WORK!

Status
Not open for further replies.

selena1

Programmer
Apr 7, 2003
69
I have a trouble with using EditMask for fields in DBGrid. EditMask work fine with dates or time, but when I set EditMask for "Phone number" field that mask doesn't work. No mather on the EditMask I can set value, for example, "(065)12 - " ,but EditMask I have set so that correct value should be "(065)123-456". How can I solve this problem?
Also, when I set EditMask for "Phone number" and use DBEdit component, mask work fine, but in case that value that I had type incorrect I get a message "Invalid input value." How can I avoid seeing this message, so that I can use my own message (I wont to use my form with some message.). I don't wont to change "ResourceString" in DBConsta.pas. I have tried to use OnSetText event.


Thanks!
 
You need to use OnGetText, here's an example:

Code:
procedure TJMSData.qryJurorSearchSSNGetText(Sender: TField;
  var Text: String; DisplayText: Boolean);
begin
  Text := Copy(sender.AsString,1, 3) + '-' + copy(sender.asString,4,2) +
   '-' + copy(sender.asString,5,4);
end;



You use OnSetText to convert it back before writing to the database.

Leslie
 
Don't use EditMask: it is a frustrating protocol.

The DBEdit works for dates and times because the data type contrains the input, not any mask.

What are you trying to end up with?

Cheers
 
I have decided to change "Resourcestring" for messages when I use DBEdit. So I have solved a problem with database field "PhoneNumber' when I use DBEdit component. But, as I have sad, "EditMask' for some reason doesn't work for "PhoneNumber" field when I use DBGrid component. So, how can I check user input in "PhoneNumber" field before I post changes to the database. PhoneNumber format is: (065)123-456.
Does anybody know some procedure for checking user input?
Cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top