Re: Formatting output of TDBEdit
- From: "Alfred ten Hoeve" <Al@xxxxxxxxxx>
- Date: Mon, 29 Oct 2007 01:17:50 +0100
"Mikael Lenfors" <mikael@xxxxxxxxxx> schreef in bericht
news:4724c510@xxxxxxxxxxxxxxxxxxxxxxxxx
Ok, thanks. Used it to implemet the following:
ADOQuery.FieldByName('TestField').OnGetText := HideZeroValues;
Procedure MyForm.HideZeroValues(Sender: TField; var Text: string;
DisplayText: Boolean);
Begin
If Sender.AsFloat = 0 Then
Text := ''
Else
Text := FloatToStr(RoundTo(Sender.AsFloat, -2));
End;
Works perfectly except for one thing, it's not called until i click on or
tab to the TDBEdit that is linked to the field. I have tried all sorts of
Refresh and Repaint but cant make it use the OnGetText until I go to the
DBEdit.
Any ideas?
regards, Mikael
Use the FieldsEditor to add the fields you want to show.
Now you can set the GetTextproperty for the field.
This way the procedures are implemented by Delphi, so you don't have to
worry about the implementation yourself.
procedure TForm1.ADOTestFieldGetText(Sender: TField; var Text: String;
DisplayText: Boolean);
begin
if Sender.AsInteger = 0 then Text := ''
else Text := FloatToStr(RoundTo(Sender.AsFloat, -2));
end;
Works for me, hope it does for you too.
Alfred.
.
- Follow-Ups:
- Re: Formatting output of TDBEdit
- From: Del Murray
- Re: Formatting output of TDBEdit
- References:
- Formatting output of TDBEdit
- From: Mikael Lenfors
- Re: Formatting output of TDBEdit
- From: Alfred ten Hoeve
- Re: Formatting output of TDBEdit
- From: Mikael Lenfors
- Formatting output of TDBEdit
- Prev by Date: Re: Formatting output of TDBEdit
- Next by Date: Re: Inserting and accessig Image (bmp) data in an SQL 2005 database.
- Previous by thread: Re: Formatting output of TDBEdit
- Next by thread: Re: Formatting output of TDBEdit
- Index(es):
Relevant Pages
|