Ver Mensaje Individual
  #4  
Antiguo 16-04-2014
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 Luvac.

A ver... fijate si te sirve de este modo:
Código Delphi [-]
...
type
  TStringGrid = class(Grids.TStringGrid)
  private
    FRowSelected: Integer;
  protected
    function CreateEditor: TInplaceEdit; override;
  public
    property RowSelected: Integer read FRowSelected write FRowSelected;
  end;

  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    procedure FormCreate(Sender: TObject);
    procedure StringGrid1Enter(Sender: TObject);
    procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
    procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    ...
  private
  public
  end;
...

implementation

{ TStringGrid }
function TStringGrid.CreateEditor: TInplaceEdit;
begin
  Result := inherited CreateEditor;
  if Focused then
    TMaskEdit(Result).Font.Color := clRed
  else
    TMaskEdit(Result).Font.Color := clBlack;
end;

{ TForm }
procedure TForm1.FormCreate(Sender: TObject);
begin
   ...
end;

procedure TForm1.StringGrid1Enter(Sender: TObject);
begin
  TStringGrid(Sender).RowSelected:= -1;
end;

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
const
  ROWCOL : array[Boolean] of TColor = (clBlack, clRed);
begin
  with TStringGrid(Sender) do
  begin
    Canvas.Font.Color:= ROWCOL[ARow = RowSelected];
    Canvas.TextOut(Rect.Left+2, Rect.Top+2, Cells[Acol,ARow]);
  end;
end;

procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
  with TStringGrid(Sender) do
  begin
    RowSelected:= ARow;
    Invalidate;
  end;
end;
...

Saludos
__________________
Daniel Didriksen

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