Ver Mensaje Individual
  #2  
Antiguo 03-10-2013
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
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; // 5 x 10

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
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita