Ver Mensaje Individual
  #13  
Antiguo 02-08-2010
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Reputación: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
He estado viendo esto un rato y me parece que puede lograrse usando simplemente la propiedad SelectedRows del DBGrid pero poniendo en false la opción dgMultiSelect.

En el evento OnDblClick del DBGrid pondríamos:

Código Delphi [-]
procedure TForm1.DBGrid1DblClick(Sender: TObject);
begin
  DBGrid1.SelectedRows.CurrentRowSelected :=
    not DBGrid1.SelectedRows.CurrentRowSelected;
end;

y en el evento OnDrawColumnCell:

Código Delphi [-]
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  if DBGrid1.SelectedRows.CurrentRowSelected then
  begin
    DBGrid1.Canvas.Brush.Color := clGreen;
    DBGrid1.Canvas.Font.Color := clHighlightText;
  end
  else
  begin
    DBGrid1.Canvas.Brush.Color := clWindow;
    DBGrid1.Canvas.Font.Color := clWindowText;
  end;

  DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;

// Saludos
Responder Con Cita