var
Form1: TForm1;
Column, Row,Cc,Rr: Longint;
R :TRect;
num :Integer;
implementation
{$R *.DFM}
procedure TForm1.DrawGrid1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
DrawGrid1.MouseToCell(X, Y, Column, Row);
if (Column=Cc) and (Row=Rr) then num :=1;
R :=Rect(Column*(DrawGrid1.DefaultColWidth+1),(Row*DrawGrid1.DefaultRowHeight+4),
(Column+1)*(DrawGrid1.DefaultColWidth+1),(Row+1)*(DrawGrid1.DefaultRowHeight+1));
if num=0 then
begin
num :=1;
DrawGrid1.Canvas.Brush.Color :=clRed;
end
else
DrawGrid1.Canvas.Brush.Color :=clBlack;
DrawGrid1.Canvas.FillRect(R);
Cc :=Column;
Rr :=Row;
num :=0;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
num :=0;
Rr :=0;
Cc :=0;
end;