Subject Re: [IBO] Re: Coloring Grids Cells
Author João Henrique de Souza
Thanks Carlos

Mas olhando os SAMPLES que acompanha o IBO, mais especificamente o CONTACTS,
eu consegui adaptar o codigo para minha necessidade.

Fiz da seguinte maneira:

procedure Tfrm_ordemproducao.grideGetCellProps(Sender: TObject; ACol,
ARow: Integer; AState: TGridDrawState; var AColor: TColor; AFont: TFont);
var
dat: Integer;
tmpFld: TIB_Column;
begin
with DataModule_CP.dts_op.Dataset do
begin
BufferRowNum := gride.DataRow[ ARow ];
if BufferRowNum > 0 then
begin
tmpFld := gride.GridFields[ gride.DataCol[ ACol ]];
if Assigned(tmpFld) and (tmpFld.FieldName = 'STATUS_OP') then
begin
dat := BufferFieldByName('STATUS').AsInteger;
AFont.Color:=clBlack;
if (dat=0) then
AColor:=clBlue;
if (dat=1) then
AColor:=clGreen;
if (dat=2) then
AColor:=clRed;
end;
end;
end;
end;


Repare q é de facil compreensão onde tem que trocar os nomes.
Muito obrigado pela resposta mesmo assim.

Abraços
João Henrique


----- Original Message -----
From: "Carlos Daniel Amaral de Mendonca" <cursodedelphi@...>
To: <IBObjects@yahoogroups.com>
Sent: Wednesday, December 01, 2004 3:55 PM
Subject: [IBO] Re: Coloring Grids Cells




No evento onDrawColumnCell você pode implementar um código similar a
este, onde "gdACE" é o nome do DBGRID!!

procedure TframeControleAcesso.gdACEDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
VAR
iC,iD : INTEGER;
begin
gdACE.CANVAS.FONT.NAME := 'ARIAL';
gdACE.CANVAS.FONT.SIZE := 9;
gdACE.CANVAS.TEXTHEIGHT('A');
//
iC := $00C4FFFF;
iD := $0088FFFF;
//
IF gdSelected in State THEN BEGIN
gdACE.CANVAS.BRUSH.COLOR := clSilver;
gdACE.CANVAS.FONT.COLOR := clBlack;
gdACE.CANVAS.FONT.STYLE := gdACE.CANVAS.FONT.STYLE + [fsBold];
END ELSE BEGIN
IF ODD(dmESHERIFF.setACE.RECNO) THEN
gdACE.CANVAS.BRUSH.COLOR := iC
ELSE
gdACE.CANVAS.BRUSH.COLOR := iD;
gdACE.CANVAS.FONT.COLOR := clBlack;
gdACE.CANVAS.FONT.STYLE := gdACE.CANVAS.FONT.STYLE -[fsBold];
END;
// Cores particulares
IF (COLUMN.FIELDNAME = 'AUTORIZADO') AND
(COLUMN.FIELD.ASSTRING = 'Não') THEN
gdACE.CANVAS.FONT.COLOR := clRed;
// fundo
gdACE.Canvas.FillRect(RECT);
// texto
gdACE.DEFAULTDRAWCOLUMNCELL(RECT, DATACOL, COLUMN, STATE);
end;






___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !
Yahoo! Groups Links










---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.804 / Virus Database: 546 - Release Date: 30/11/2004