Re: TZF - TzGrid Colors

[email protected] Mon, 3 Nov 2003 19:03:38 EST
Newsgroups gmane.comp.lang.delphi.topaz
Message-ID <[email protected]>
Eitan,
In the following code that you provided, I get an
error message (Variable not defined) at the statement:

Table1Size.AsInteger

   if DataCol=TStringGrid(Sender).LeftCol-1 then
     if Table1Size.AsInteger>10
       then UnColor:=clRed
       else UnColor:=clBlack;

Do you have any hints??

Thanks,
Bob Watson
__________________________________________



In a message dated 10/21/2003 10:50:38 AM Eastern Standard Time, 
[email protected] writes:


> Try this:
> 
> Show a ROW of a DBGrid in a different color
> We have another trick to show columns of a DBGrid in different color, in
> short, the one:
> 
> [61] - Display a DBGrid column in a different color
> 
> In this other one, we will change the color of a whole line, that is to say,
> of a whole register (a register or those that complete a certain condition).
> 
> The theme is to get that the comparison of if it is a record to show of
> another color, be not carried out once for each field of each record, but
> once for registration, winning this way in speed.
> For it, we will calculate the color with which will paint the record just in
> one of the columns of the DBGrid, using this color calculated in the rest of
> the columns.
> So that this serves?, for example, do imagine a list of clients shown in a
> DBGrid... could we mark in red those clients that owe us money...
> 
> The example:
> 
> We will use the Animals.DBF table of the Delphi's demos:
> 
> # Put a Table and asociate it with Animals.DBF table of the Delphi's demos
> 
> # Put a Datasource link to the table
> 
> # Put a DBGrid (DBGrid1) link to DataSource
> 
> # Declare a TColor variable in the private of the form:
> 
> 
>    private
>      { Private declarations }
>      UnColor:TColor;
> 
> 
> # Put this code in the OnDrawColumnCell of the DBGrid1:
> 
> procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
>    DataCol: Integer; Column: TColumn; State: TGridDrawState);
> begin
>    {Si es la primera columna, calculamos el color}
>    {UnColor debe estar declarada global a la form}
> 
>    {If it is the first column, we calculate the color}
>    {UnColor should be declared as global to the form}
>    if DataCol=0 then
>      if Table1Size.AsInteger>10
>        then UnColor:=clRed
>        else UnColor:=clBlack;
> 
>    with (Sender As TDBGrid).Canvas do
>    begin
>      Font.Color:=UnColor;
>      FillRect(Rect);
>      TextOut(Rect.Left, Rect.Top, Column.Field.AsString);
>    end;
> end;
> 
> A tip improvement:
> 
> procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
>    DataCol: Integer; Column: TColumn; State: TGridDrawState);
> begin
>    {Si es la primera columna, calculamos el color}
>    {UnColor debe estar declarada global a la form}
> 
>    {If it is the first column, we calculate the color}
>    {UnColor should be declared as global to the form}
>    if DataCol=TStringGrid(Sender).LeftCol-1 then
>      if Table1Size.AsInteger>10
>        then UnColor:=clRed
>        else UnColor:=clBlack;
> 
>    with (Sender As TDBGrid).Canvas do
>    begin
>      Font.Color:=UnColor;
>      FillRect(Rect);
>      TextOut(Rect.Left, Rect.Top, Column.Field.AsString);
>    end;
> end;
> 
> Best wishes,
> 
> Eitan.
> URL: http://perso.wanadoo.fr/eitang
> 

--^----------------------------------------------------------------
This email was sent to: [email protected]

EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt
Or send an email to: [email protected]

TOPICA - Start your own email discussion group. FREE!
http://www.topica.com/partner/tag02/create/index2.html
--^----------------------------------------------------------------