2.procedure DrawGrid(Grid:TDBGrid;const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if odd(Grid.DataSource.DataSet.RecNo) then//奇偶行判断
begin
Grid.Canvas.Font.Color:=clblack;
Grid.Canvas.Brush.color:=clwhite;
end
else
begin
Grid.Canvas.Font.Color:=clblack;
Grid.Canvas.Brush.color:=clcream;
end;
if Grid.SelectedRows.CurrentRowSelected then//dgRowSelect和dgMultiSelect都为真时有效
begin
Grid.Canvas.Font.Size:=12;
Grid.Canvas.Font.Style:=[fsBold];
Grid.Canvas.Font.Color:=clwhite;
Grid.Canvas.Brush.color:=clNavy;
end;
Grid.DefaultDrawColumnCell(rect,datacol,column,state);
end;
在OnDrawColumnCell事件中放入DrawGrid((sender as TDBGrid),Rect,DataCol,Column,State)就大功告成了。
3、checkbox属性为true即可