Ver Mensaje Individual
  #11  
Antiguo 28-07-2016
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
Una pequeña variante:

Código Delphi [-]
interface

type
  TStringGrid = class(Grids.TStringGrid)
  protected
    function CreateEditor: TInplaceEdit; override;
  end;

implementation

{ TStringGrid }

const
  clHiglightCell = clYellow;

type
  TEditor = class(TInPlaceEdit);

function TStringGrid.CreateEditor: TInplaceEdit;
begin
  Result := inherited CreateEditor;
  TEditor(Result).Color := clHiglightCell;
end;

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
  with Sender as TStringGrid do
  begin
    if (ARow = Row) then
    begin
      if (ACol = Col) then
        Canvas.Brush.Color := clHiglightCell
      else
      begin
        Canvas.Brush.Color := clHighlight;
        Canvas.Font.Color := clHighlightText;
      end;

      Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
    end;
  end;
end;

procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean);
begin
  with Sender as TStringGrid do
  begin
    if ARow <> Row then
      Invalidate;
  end;
end;

DefaultDrawing debe ser true y goRowSelect debe ser false.

LineComment Saludos
Responder Con Cita