Re: Formatting output of TDBEdit



"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.


.



Relevant Pages

  • Re: D2006 - Not good for UI designing.
    ... mail with complaints? ... there is one thing that the earlier versions of Delphi had - it ... > which tab. ... I might have just spoken about one of the features missing - ...
    (borland.public.delphi.non-technical)
  • Re: anybody like auto indent?
    ... I've been using the bloody tool for years and ... If you have a selected block of text the logical ... > thing to assume is that TAB will ident. ... > (there are other mappings available in Delphi that support this). ...
    (borland.public.delphi.non-technical)
  • Re: anybody like auto indent?
    ... If you have a selected block of text the logical thing to assume is that TAB will ident. ... I'd like Delphi to be as "new user friendly" out-of-the-box as possible while still remaining a powerful IDE for us long-time users. ... while the expert will help us professional users it isn't going to help newbies. ... The only way a newbie would find out about this is first-hand and they may complain, ...
    (borland.public.delphi.non-technical)
  • Re: Eureka?
    ... I have all three off, it's faster but not Delphi 7 speeds, with all my ... > I think I might have solved the problem with delays when switching tabs in ... > Now I can switch from tab to tab as fast or even faster than in D7. ...
    (borland.public.delphi.non-technical)
  • Re: Eureka?
    ... I have Delphi 2005 Enterprise ... > I think I might have solved the problem with delays when switching tabs in ... > the editor. ... > Now I can switch from tab to tab as fast or even faster than in D7. ...
    (borland.public.delphi.non-technical)