以下代碼完成對當前記錄著色
dataSource下事件
procedure TForm1.DataSource1DataChange(Sender: TObject;
Field: TField);
begin
pd:=query1.RecNo;
dbgrid1.Refresh;
end;
Grid下事件
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect;
DataCol: Integer;
Column: TColumn;
State: TGridDrawState);
begin
if query1.RecNo=pd then
begin
DBGrid1.Canvas.font.Color:=clmaroon;
DBGrid1.Canvas.font.Style:=[fsbold];
dbgrid1.Canvas.Brush.Color:=clinfobk;
dbgrid1.columns.items[0].font.color:=clred;
//dbgrid1.Canvas.Brush.style:=bscross;
dbgrid1.DefaultDrawcolumncell(rect,datacol,column,state);
end;
end;