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

 
 
Herramientas Buscar en Tema Desplegado
  #25  
Antiguo 08-01-2011
cloayza cloayza is offline
Miembro
 
Registrado: may 2003
Ubicación: San Pedro de la Paz, Chile
Posts: 947
Poder: 25
cloayza Tiene un aura espectacularcloayza Tiene un aura espectacular
Cita:
Empezado por Casimiro Notevi Ver Mensaje
Nada, acaba alternando colores incorrectamente.
Amigo he implementado el codigo en ejemplo de Chris, y me anda de maravillas...

Te copio el codigo completo de la unidad.

Código Delphi [-]
unit Unit24;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, IBCustomDataSet, IBDatabase, StdCtrls, ComCtrls, Grids, DBGrids;

type
  TForm24 = class(TForm)
    gr1: TDBGrid;
    DS1: TDataSource;
    dtp1: TDateTimePicker;
    lb1: TLabel;
    btn1: TButton;
    DB1: TIBDatabase;
    TR1: TIBTransaction;
    QR1: TIBDataSet;
    QR1CODIGOAPUNTE: TIntegerField;
    QR1CODIGOEMPRESA: TIntegerField;
    QR1EJERCICIO: TSmallintField;
    QR1NUMEROASIENTO: TIntegerField;
    QR1LINEAASIENTO: TIntegerField;
    QR1FECHAASIENTO: TDateField;
    QR1CODIGOCUENTA: TIBStringField;
    QR1CONCEPTO: TIBStringField;
    QR1DEBE: TFloatField;
    QR1HABER: TFloatField;
    QR1FECHACREACION: TDateField;
    QR1HORACREACION: TTimeField;
    procedure btn1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure gr1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    procedure dtp1Exit(Sender: TObject);
  private
    { Private declarations }
{    nValorAnt: Integer;
    FColor, BColor: TColor;
    UltimoValor: Variant;
    BoolSwitch: Boolean;
    GrupoImpar: String;
}
  public
    { Public declarations }
    Sombra:Boolean;
    List:TStrings;
  end;

var
  Form24: TForm24;

implementation

{$R *.dfm}

procedure TForm24.btn1Click(Sender: TObject);
begin
  db1.Open;
  tr1.Active:=True;
  qr1.Close;
  qr1.selectsql.text := 'select * from tbapuntes where codigoempresa=2 and ejercicio=2 and codigoestadoapunte=2 '+
                        'and fechaasiento  between :fechadesde and :fechahasta '+
                        'order by codigoempresa, ejercicio, numeroasiento, lineaasiento';
  qr1.Params[0].AsDate := dtp1.Date;
  qr1.Params[1].AsDate := dtp1.Date;

  if Assigned(List) then
     List.Clear;

  // inicializar los datos del control de grupo
  qr1.Open;
  gr1.SetFocus;
end;

procedure TForm24.dtp1Exit(Sender: TObject);
begin

  btn1.SetFocus;
end;

procedure TForm24.FormClose(Sender: TObject; var Action: TCloseAction);
begin
     DB1.Close;
end;

procedure TForm24.gr1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
   index:Integer;
   fColor:TColor;
begin
      if Not Assigned(List) then
         List:=TStringList.Create;

      with TDBGrid(Sender) do
      begin
         if (gdFocused in State) then
         begin
            Canvas.Font.Color := clWhite;
            Canvas.Brush.Color := clHighlight;
         end
         else
         begin
              Index:=List.IndexOf(DataSource.DataSet.FieldByName('NUMEROASIENTO').AsString);
              if Index=-1 then
              begin
                   if Sombra then fColor:=clYellow  else fColor:=clInfoBk;

                   //fColor:=RGB(Random(205),Random(205),Random(205));

                   index:=List.AddObject(Datasource.Dataset.FieldByName('NUMEROASIENTO').AsString, Pointer(fColor));

                   Sombra := not Sombra;
              end;

              Canvas.Font.Color := clBlack;
              Canvas.Brush.Color := TColor(List.Objects[index]);

              DefaultDrawColumnCell(Rect, DataCol, Column, State);
          end;
      end;
end;

end.

Saludos cordiales
Responder Con Cita
 



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
Alternar dos colores en las lineas de un DBGrid. jealousy OOP 4 07-05-2014 15:45:23
colores en un dbgrid frf_84 Gráficos 2 07-12-2004 12:14:57
dbgrid con colores Giniromero Conexión con bases de datos 7 08-07-2004 16:26:29
dbgrid en colores sebas Conexión con bases de datos 2 09-07-2003 09:16:14
Colores en una DBGrid REDCOM Varios 2 26-05-2003 20:42:58


La franja horaria es GMT +2. Ahora son las 15:23:57.


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