Una pequeña variante:
Código Delphi
[-]
interface
type
TStringGrid = class(Grids.TStringGrid)
protected
function CreateEditor: TInplaceEdit; override;
end;
implementation
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