Norm-al
asked on
How to format DBTextEdit (float field) as a percent?
I have a data entry form that has a DBTextEdit field pulling in a float but when I show the form, it needs to show as a percentage. I have this same field in a grid and the procedure I have is the following:
if (AText <> NULL) OR (AText <> '') then begin
AText := FloatToStr(StrToFloatDef(A Text,0) * 100);
AText := AText + '%';
end;
I tried this in both the OnValidate and OnNewLookupDisplayText and those did not work... any ideas how to accomplish this? I'm sure it will be simple and I am just overlooking something really silly... thanks for your help!
if (AText <> NULL) OR (AText <> '') then begin
AText := FloatToStr(StrToFloatDef(A
AText := AText + '%';
end;
I tried this in both the OnValidate and OnNewLookupDisplayText and those did not work... any ideas how to accomplish this? I'm sure it will be simple and I am just overlooking something really silly... thanks for your help!
ASKER
I dont have an event for OnGetText for the DBTextEdit, I only have that in the grid.
I was meaning in the Table.field.ongettext
ASKER
Oh ok... I already have that procedure for the field in the table but I need to also format to percent for the field that is not in the table, it is just an edit box on a form.
What is the class of the component?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked great, thanks!
if (AText <> NULL) OR (AText <> '') then begin
AText := FormatFloat('#,### %',(StrToFloatDef(AText,0)