如果仅仅是改变当前行的颜色,可如此:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, Db, DBTables;
type
TCustomDBGridCracker = class(TCustomDBGrid);
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
with TCustomDBGridCracker(Sender) do
begin
if DataLink.ActiveRecord = Row - 1 then
Canvas.Brush.Color := clRed
else
Canvas.Brush.Color := clWhite;
DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
end.
~~~~~~~~~~~~~~~~~~~~~~~~~~
to fx:
我是把要删除的行的记录号放在Dl中.