Subject | RE: [IBO] Question about TIB_Grid.OnDrawCell |
---|---|
Author | Thomas Steinmaurer |
Post date | 2003-11-05T12:43:30Z |
Ronni,
<quote>
I'm using the OnGetCellProps event. Dependent of a column value
the font and background color is set.
An example (not fully checked, but you might get the idea):
procedure TfmMainForm.IB_Grid1GetCellProps(Sender: TObject; ACol, ARow: Integer;
AState: TGridDrawState; var AColor: TColor; AFont:
TFont);
begin
with IB_Query1 do
begin
if Active and (ARow > 0) and (ACol > 0) then
begin
BufferRowNum := IB_Grid1.DataRow[ARow];
if (BufferRowNum > 0) then
begin
if not (gdSelected in AState) then
begin
AFont.Color := BufferFieldByName('FONTCOLOR').AsInteger;
AColor := BufferFieldByName('BACKGROUNDCOLOR').AsInteger;
end;
end;
end;
end;
end;
The Contact sample in %IBO%\Samples\Contact might be useful too.
</quote>
HTH,
Thomas Steinmaurer
The IB LogManager Product Family
Logging/Auditing Suite for InterBase and Firebird
http://www.iblogmanager.com
> how can I color a complete row, depening on a column value:From an old post of mine:
>
> for example :
>
> Field1 Field2 Field3
> test 1 abc
> test 2 abc
> test 3 abc
> test 2 abc
> test 1 abc
> test 1 abc
>
> I want to draw all colums, where Field2 = 1 in another color.
> I know, that I need to it with the event OnDrawCell.
>
> Who can help?
<quote>
I'm using the OnGetCellProps event. Dependent of a column value
the font and background color is set.
An example (not fully checked, but you might get the idea):
procedure TfmMainForm.IB_Grid1GetCellProps(Sender: TObject; ACol, ARow: Integer;
AState: TGridDrawState; var AColor: TColor; AFont:
TFont);
begin
with IB_Query1 do
begin
if Active and (ARow > 0) and (ACol > 0) then
begin
BufferRowNum := IB_Grid1.DataRow[ARow];
if (BufferRowNum > 0) then
begin
if not (gdSelected in AState) then
begin
AFont.Color := BufferFieldByName('FONTCOLOR').AsInteger;
AColor := BufferFieldByName('BACKGROUNDCOLOR').AsInteger;
end;
end;
end;
end;
end;
The Contact sample in %IBO%\Samples\Contact might be useful too.
</quote>
HTH,
Thomas Steinmaurer
The IB LogManager Product Family
Logging/Auditing Suite for InterBase and Firebird
http://www.iblogmanager.com