Hola paquechu.
Si te arreglas con el evento
OnDblClick te puedo sugerir este código:
Código Delphi
[-]
...
implementation
const
MAXCOL = 4;
MAXROW = 9;
var
vPainted : array[0..MAXCOL, 0..MAXROW] of Boolean;
procedure TForm1.FormCreate(Sender: TObject);
var
c,f: Integer;
begin
for c := 0 to MAXCOL do
for f := 0 to MAXROW do
vPainted[c,f] := False;
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[vPainted[ACol,ARow]];
Canvas.FillRect(Rect);
DrawText(Canvas.Handle,PChar(Cells[ACol,ARow]),-1,Rect,DT_SINGLELINE);
end;
end;
procedure TForm1.StringGrid1DblClick(Sender: TObject);
begin
with TStringGrid(Sender) do
begin
vPainted[Col, Row] := not vPainted[Col, Row];
Invalidate;
end;
end;
end.
Lamentablemente en el componente
TStringGrid el evento
OnClick se dispara también ante otras acciones que el click del mouse ...
Saludos