Ver Mensaje Individual
  #2  
Antiguo 02-11-2011
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 Choclito.

Se me ocurren dos formas ahora.

Con un TButton podrías hacer:
Código Delphi [-]
...
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  if (gdSelected in State) and FPintar then
    with (Sender as TDBGrid) do
    begin
      Canvas.Brush.Color:= clRed;
      Canvas.Font.Color:= clWhite;
      DefaultDrawColumnCell(Rect, DataCol, Column, State);
      MessageBeep(MB_OK);  // Beep
      FPintar:= False;
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  FPintar:= True;  // variable privada a TForm1
  DBGrid1.Invalidate;
end;

Con un TCheckBox, para que quede el pintado activo según la propiedad Checked:
Código Delphi [-]
...
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  if (gdSelected in State) and CheckBox1.Checked then
    with (Sender as TDBGrid) do
    begin
      Canvas.Brush.Color:= clRed;
      Canvas.Font.Color:= clWhite;
      DefaultDrawColumnCell(Rect, DataCol, Column, State);
      MessageBeep(MB_OK);  //Beep
    end;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  DBGrid1.Invalidate;
end;

Un saludo.

Edito: Se me olvidaba el sonido...
__________________
Daniel Didriksen

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

Última edición por ecfisa fecha: 02-11-2011 a las 01:46:57. Razón: Agregar código de sonido.
Responder Con Cita