You can use the TField.OnGetText event or the TNumericField.DisplayFormat property to change how text is displayed.
Since you have TStringField numbers, you have two options:
- use the
TNumericField property and DisplayFormat - use the
OnGetText event and create your own string formatting
Edit:
Sam used this approach:
I implemented the OnSetText and OnGetText event handlers. I already had Edit Mask 9999 9999 9999 9999;1;_ , so OnSetText was just
TStringField(Sender).Value := Trim(Text);
and OnGetText were just
sValue := TStringField(Sender).Value; Text := Format('%s %s %s %s', [Copy(sValue, 1, 4), Copy(sValue, 5, 4), Copy(sValue, 9, 4), Copy(sValue, 13, 4)]);
It works great. Thanks.
source share