Subject | ib_grid.ondrawcell and ongetcellprops |
---|---|
Author | james_027 |
Post date | 2003-07-10T07:05:53Z |
I have read it somewhere else that if I want to customize my grid I
should use the ongetcellprops. what is the purpose of the ondrawcell?
I try to study the the ongetcellprops on the contact sample and I
have my grid working as I want to, but there are some thing I dont
understand, can somebody kindly explain it to me?
here is the code for your convinience ...
procedure TfrmContact.grContactGetCellProps(Sender: TObject; ACol,
ARow: Integer; AState: TGridDrawState; var AColor: TColor; AFont:
TFont);
var
dat: string;
tmpFld: TIB_Column;
begin
// This provides an example of how colors and fonts can be customized
on an
// individual basis.
// It also shows how any row of data can be peeked at without having
to worry
// about messing up the display of data.
if dsContact.Active then
begin
with dsContact.DataSet do
begin
BufferRowNum := grContact.DataRow[ ARow ];
if BufferRowNum > 0 then
begin
// This provides an example of how colors can be customized on an
// individual cell basis.
tmpFld := grContact.GridFields[ grContact.DataCol[ ACol ]];
if Assigned( tmpFld ) and ( tmpFld.FieldName = 'LASTNAME' )
then
begin
dat := BufferFieldByName('CON_TYPE').AsString;
if dat = 'FAMILY' then
begin
if AColor = grContact.Color then
AColor := clLime;
end;
end;
if AFont.Color <> clHighlightText then
begin
dat := BufferFieldByName('CON_TYPE').AsString;
if dat = 'FRIEND' then
AFont.Color := clBlue
else
if dat = 'FAMILY' then
AFont.Color := clRed
else
AFont.Color := clWindowText;
end;
end;
end;
end;
end;
should use the ongetcellprops. what is the purpose of the ondrawcell?
I try to study the the ongetcellprops on the contact sample and I
have my grid working as I want to, but there are some thing I dont
understand, can somebody kindly explain it to me?
here is the code for your convinience ...
procedure TfrmContact.grContactGetCellProps(Sender: TObject; ACol,
ARow: Integer; AState: TGridDrawState; var AColor: TColor; AFont:
TFont);
var
dat: string;
tmpFld: TIB_Column;
begin
// This provides an example of how colors and fonts can be customized
on an
// individual basis.
// It also shows how any row of data can be peeked at without having
to worry
// about messing up the display of data.
if dsContact.Active then
begin
with dsContact.DataSet do
begin
BufferRowNum := grContact.DataRow[ ARow ];
if BufferRowNum > 0 then
begin
// This provides an example of how colors can be customized on an
// individual cell basis.
tmpFld := grContact.GridFields[ grContact.DataCol[ ACol ]];
if Assigned( tmpFld ) and ( tmpFld.FieldName = 'LASTNAME' )
then
begin
dat := BufferFieldByName('CON_TYPE').AsString;
if dat = 'FAMILY' then
begin
if AColor = grContact.Color then
AColor := clLime;
end;
end;
if AFont.Color <> clHighlightText then
begin
dat := BufferFieldByName('CON_TYPE').AsString;
if dat = 'FRIEND' then
AFont.Color := clBlue
else
if dat = 'FAMILY' then
AFont.Color := clRed
else
AFont.Color := clWindowText;
end;
end;
end;
end;
end;