Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Coloboración Paypal con ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
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
  #2  
Antiguo 28-07-2016
Avatar de santiago14
santiago14 santiago14 is offline
Miembro
 
Registrado: sep 2003
Ubicación: Cerrillos, Salta, Argentina
Posts: 585
Poder: 23
santiago14 Va por buen camino
Wink

Buenísimo.
Muchas gracias.
__________________
Uno es responsable de lo que hace y de lo que omite hacer.
Responder Con Cita
  #3  
Antiguo 28-07-2016
Avatar de BDWONG
BDWONG BDWONG is offline
Miembro
NULL
 
Registrado: nov 2013
Posts: 113
Poder: 13
BDWONG Va por buen camino
Genial ecfisa entras mas soluciones mejor le voy a dar una revisada a tu codigo.
Saludos..
Responder Con Cita
  #4  
Antiguo 28-07-2016
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Poder: 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
Respuesta



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 22:41:44.


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