DBGrid.Options属性dgRowSelect=False时,通过重绘使DBGrid有选中行的效果。
DrawColumnCell事件代码如下:
with TMyDBGrid(Sender) do
begin
if DataLink.ActiveRecord = Row-1 then
begin
Canvas.Font.Color := $00000000;
Canvas.Brush.Color := $00C1F0FF;
end
else
begin
Canvas.Brush.Color := Color;
Canvas.Font.Color := Font.Color;
end;
DefaultDrawColumnCell(Rect,DataCol,Column,State););
end;
DrawColumnCell事件代码如下:
with TMyDBGrid(Sender) do
begin
if DataLink.ActiveRecord = Row-1 then
begin
Canvas.Font.Color := $00000000;
Canvas.Brush.Color := $00C1F0FF;
end
else
begin
Canvas.Brush.Color := Color;
Canvas.Font.Color := Font.Color;
end;
DefaultDrawColumnCell(Rect,DataCol,Column,State););
end;