Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #8  
Antiguo 28-07-2016
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 38
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.
Cita:
Empezado por santiago14 Ver Mensaje
...
Lo explico, la grilla tiene la fila seleccionada en un color (azul por ejemplo), y la celda actual en otro color (amarillo...) ...
Te pongo un ejemplo con otra opción, fijate si te sirve:

Código Delphi [-]
...
interface

uses ..., Mask;

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

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

...

implementation

const
  COLORHIGH = clYellow;
  COLORLOW  = clBlue;

{ TStringGrid (Respetar los colores en la edición) }
function TStringGrid.CreateEditor: TInplaceEdit;
begin
  Result := inherited CreateEditor;
  if Focused then
    TMaskEdit(Result).Color := COLORHIGH
  else
    TMaskEdit(Result).Color := COLORLOW;
end;

var
  LastRowSel: Integer;

// cargar algunos datos en el StringGrid
procedure TForm1.FormCreate(Sender: TObject);
var
  c, r: Integer;
  sg: TStringGrid;
begin
  sg := StringGrid1;
  sg.Rows[0].CommaText := 'NRO_OP,TITULO_AVISO,TEXTO_AVISO';
  
  for c := sg.FixedCols to sg.ColCount-1 do
  begin
    sg.ColWidths[c] := 120;
    for r := sg.FixedRows to sg.RowCount -1 do
    begin
      sg.Cells[c, r] := Format('%.12d',[c+r]);
      sg.Objects[c, r] := TObject(sg.Color);   // color por defecto: El del StringGrid !
    end;
  end;
  sg.ColWidths[1] := 300;
  LastRowSel := sg.Row;
  
end;

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  sg: TStringGrid;
begin
  sg := TStringGrid(Sender);
  if not (gdFixed in State) then
  begin
    sg.Canvas.Brush.Color := TColor(sg.Objects[ACol, ARow]);
    sg.Canvas.FillRect(Rect);
    sg.Canvas.TextOut(Rect.Left+2, Rect.Top+2, sg.Cells[Acol,ARow]);
  end;
end;

procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
  var CanSelect: Boolean);
var
  sg: TStringGrid;
  c: Integer;
begin
  sg := TStringGrid(Sender);
  // anterior línea seleccionada en el color del StringGrid
  for c := sg.FixedCols to sg.ColCount - 1 do
    sg.Objects[c, LastRowSel] := TObject(sg.Color);

  // nueva linea seleccionada
  for c := sg.FixedCols to sg.ColCount - 1 do
    if c = aCol then
      sg.Objects[c, ARow] := TObject(COLORHIGH)
    else
     sg.Objects[c, ARow] := TObject(COLORLOW);

  LastRowSel := ARow; // ultima línea = nueva línea
end;

end.

Salida:


Saludos
__________________
Daniel Didriksen

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


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
como ver un tipo de datos de una grilla en otra grilla en el mismo form? calistian Varios 5 01-10-2008 19:29:04
La Grilla YOSMITH Gráficos 1 13-06-2007 22:11:50
Coleres en las Grilla josem Varios 6 06-06-2007 20:05:15
Grilla :-( AndyLupa Varios 0 20-04-2006 15:51:18
bandas en grilla Andrea Martinez Varios 0 10-07-2004 06:42:22


La franja horaria es GMT +2. Ahora son las 21:26:03.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi