Board index » delphi » Grid custom draw - urgent help needed

Grid custom draw - urgent help needed

Beacuse I am in south-east europe, I need date and currency to be drawn
different from delphi standard, (e.g. I don't want date to have form
"mont/day/twodigityear", but "day.mont.year", yaer can be twodigit or
fourdigit, and currency: not "12345.67", but "12.345,67" or "12.345,67XXX",
where "XXX" is sometnig like "$", "DM", "Fr", "KM"). How can it be done? I
tryed OnDrawColumnCell:

procedure TMainForm.Draw(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Column.Field.DataType=ftCurrency then
  begin
  {This is totally skipped}
  end else
  if Column.Field.DataType=ftDate then
    begin
    {Here is Ok, since it doesn't draw anyting}
    end else
      Grid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;

but there is a problem. It does draw currency fields (Look at the code).
Thanks in advance.

 

Re:Grid custom draw - urgent help needed


Doesn't delphi follow the 'Reginal options' that you can set in windows
itself?????

greetings
Rens

Quote
"Dzenan Zukic" <zzm...@hotmail.com> wrote in message

news:903e1k$j3i16@ns4.bih.net.ba...
Quote
> Beacuse I am in south-east europe, I need date and currency to be drawn
> different from delphi standard, (e.g. I don't want date to have form
> "mont/day/twodigityear", but "day.mont.year", yaer can be twodigit or
> fourdigit, and currency: not "12345.67", but "12.345,67" or
"12.345,67XXX",
> where "XXX" is sometnig like "$", "DM", "Fr", "KM"). How can it be done? I
> tryed OnDrawColumnCell:

> procedure TMainForm.Draw(Sender: TObject; const Rect: TRect;
>   DataCol: Integer; Column: TColumn; State: TGridDrawState);
> begin
> if Column.Field.DataType=ftCurrency then
>   begin
>   {This is totally skipped}
>   end else
>   if Column.Field.DataType=ftDate then
>     begin
>     {Here is Ok, since it doesn't draw anyting}
>     end else
>       Grid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
> end;

> but there is a problem. It does draw currency fields (Look at the code).
> Thanks in advance.

Re:Grid custom draw - urgent help needed


First modify ShortDateFormat and CurrencyString/CurrencyFormat and if you
still don't like the result modify the displayed string in the OnGetText
event handler of the field and NOT in the OnDrawCell event handler of the
grid !

"Dzenan Zukic" <zzm...@hotmail.com> schreef in bericht
news:903e1k$j3i16@ns4.bih.net.ba...

Quote
> Beacuse I am in south-east europe, I need date and currency to be drawn
> different from delphi standard, (e.g. I don't want date to have form
> "mont/day/twodigityear", but "day.mont.year", yaer can be twodigit or
> fourdigit, and currency: not "12345.67", but "12.345,67" or
"12.345,67XXX",
> where "XXX" is sometnig like "$", "DM", "Fr", "KM"). How can it be done? I
> tryed OnDrawColumnCell:

> procedure TMainForm.Draw(Sender: TObject; const Rect: TRect;
>   DataCol: Integer; Column: TColumn; State: TGridDrawState);
> begin
> if Column.Field.DataType=ftCurrency then
>   begin
>   {This is totally skipped}
>   end else
>   if Column.Field.DataType=ftDate then
>     begin
>     {Here is Ok, since it doesn't draw anyting}
>     end else
>       Grid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
> end;

> but there is a problem. It does draw currency fields (Look at the code).
> Thanks in advance.

Re:Grid custom draw - urgent help needed


Ehehehehe...
You know windows, it has to be reinstalled every 6 months, if you want to be
operable...
I have us regional settiings (because I used to US keyboard layout). Within
last windows instalation, I've forgotten to change this (currency format,
etc). Thanks:)))))

Re:Grid custom draw - urgent help needed


Thnx. In the meanwhile, i saw ongettext event, so i wrote the code...
But there is a problem. Code:

procedure TMainForm.FormCreate(Sender: TObject);
var i: Byte;
begin
Query.Open;
while not Query.Eof do
  for i:=0 to Grid.Columns.Count-1 do
    if Grid.Columns[i].Field.DataType=ftCurrency then
      Grid.Columns[i].Field.OnGetText:=CGetText;
end;

procedure TMainForm.CGetText(Sender: TField; var Text: String; DisplayText:
Boolean);
var c: Currency;
    neg: Boolean;
    i: Int64;
begin{Kod za prikaz Currency polja}
c:=Sender.AsCurrency;
neg:=False;
if c<0 then
  begin
  c:=Abs(c);
  neg:=True;
  end;
if frac(c)<0.995 then
  Text:=IntToStr(Round(Frac(c)*100))
  else begin
  Text:='00';
  c:=c+1;
  end;
i:=Trunc(c);
repeat
Text:=IntToStr(i mod 1000)+'.'+Text;
i:=i div 1000;
until i=0;
if neg then Text:='-'+Text;
end;

BUT, when the program is loading, it took over 20 secs, so I tryed to kill
it (Ctrl+Alt+Del, End Task, on Win98SE), but then system stop
functioning(blue screen of death- computer: cel266, 64mb sdram). What
happened?

Re:Grid custom draw - urgent help needed


I've put the proper reg. settings, but it is not showing currency field
properly. In windows' reg. settings, currency format is: "123.456,90", but
the grid is showing: "123456,9". Why? How to correct it?

Other Threads