Board index » delphi » DisplayFormat

DisplayFormat

Hi,
  How can I set the Display Format of  TDBEdit or TDBText whithout using
TField properties.
Example: Display the "123456" (double) to "123,456.00".
The reason is because there will be alot of steps if we use Tfield property.
i.e. We need to double click on the TDataSet -> add Fields -> Select all or
related field ->
Click OK -> select the particular field -> go to object inspecter, then we
can set the
Display format as '#,###,###,#0'. This is bad if I use dynamic queries.
Any suggestion?

TIA
Hott

 

Re:DisplayFormat


Correct me if I am wrong...

procedure TForm1.FormCreate(Sender: TObject);
begin
  DBText1.Field.OnGetText:= SF;
end;

procedure TForm1.SF(Sender: TField; var Text: String; DisplayText: Boolean);
begin
  With TDBText(Sender) do
  begin
    Text:= Format('%.2n', [Sender.AsFloat]);
  end;
end;

Quote
Hott <kkg...@nospam.mail.com> wrote in message news:3b4a7461_2@dnews...
> Hi,
>   How can I set the Display Format of  TDBEdit or TDBText whithout using
> TField properties.
> Example: Display the "123456" (double) to "123,456.00".
> The reason is because there will be alot of steps if we use Tfield
property.
> i.e. We need to double click on the TDataSet -> add Fields -> Select all
or
> related field ->
> Click OK -> select the particular field -> go to object inspecter, then we
> can set the
> Display format as '#,###,###,#0'. This is bad if I use dynamic queries.
> Any suggestion?

> TIA
> Hott

Re:DisplayFormat


Quote
>  How can I set the Display Format of  TDBEdit or TDBText whithout using
>TField properties.
>Example: Display the "123456" (double) to "123,456.00".
>The reason is because there will be alot of steps if we use Tfield property.
>i.e. We need to double click on the TDataSet -> add Fields -> Select all or
>related field ->
>Click OK -> select the particular field -> go to object inspecter, then we
>can set the
>Display format as '#,###,###,#0'. This is bad if I use dynamic queries.

You don't need persistent Tfields to set displayformat property in code

  (fieldbyName(YourdateField') As TdateTimeField).DisplayFormat := 'mm/dd/yy';

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads