procedure TForm1.FormCreate(Sender: TObject);
var
c,f: Integer;
begin
for c := 0 to StringGrid1.ColCount-1 do
for f := 0 to StringGrid1.RowCount-1 do
StringGrid1.Objects[c,f] := Pointer(False);
end;
procedure TForm1.StringGrid1DblClick(Sender: TObject);
begin
with TStringGrid(Sender) do
begin
StringGrid1.Objects[Col, Row] := Pointer(not Boolean(StringGrid1.Objects[Col, Row]));
Invalidate;
end;
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
const
COLORS : array[Boolean] of TColor = (clWindow, clGreen);
begin
with TStringGrid(Sender) do
begin
Canvas.Brush.Color := COLORS[Boolean(StringGrid1.Objects[ACol, ARow])];
Canvas.FillRect(Rect);
DrawText(Canvas.Handle,PChar(Cells[ACol,ARow]),-1,Rect,DT_SINGLELINE);
end;
end;