Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #6  
Antiguo 03-07-2004
__cadetill __cadetill is offline
Miembro
 
Registrado: may 2003
Posts: 3.387
Poder: 27
__cadetill Va por buen camino
Hola Gydba

Ante todo gracias por el código, pero ya lo había implementado cuando lo he leído
Por cierto, lo has probado? Si quieres usar ese componente, te aconsejo que lo hagas Yo lo he probado y me daba Access Violations. He corregido ese error cambiando el procedimiento ColWidthsChanged de esta manera
Código Delphi [-]
procedure TCustomDBGrid1.ColWidthsChanged;
begin
  inherited ColWidthsChanged;

  if DataLink.Active then
    if not bColMoved then begin
      if Assigned(varColWidthChg) then varColWidthChg(Self, varCurrentCell.X);
    end;
  bColMoved := False;
end;
pero ahora me devolvía siempre una columna más de la que tocaba (cosa que ya desistí mirarme).

Mira lo que yo he hecho (por si interesa a alguien)

Si me he dejado algo o me sobra algo, ya me perdonaréis, pero es que el componente tiene otras funciones (y no es plan de poner todo el código). Si queréis ver el código completo, en breves lo subiré a mi web (a la que termine unos detallitos más, seguramente este finde).

Código Delphi [-]
type
  TColumnResized = procedure(Sender: TObject; Column: TColumn) of object;

  TExtendedGrid = class(TRxDbGrid)
  private
    FListCols: TDBGridColumns;
    FOnColumnResized: TColumnResized;

    function MismasColumnas: boolean;
  protected
    procedure LinkActive(Value: Boolean); override;
    procedure ColWidthsChanged; override;
    procedure ColumnMoved(FromIndex, ToIndex: Longint); override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property OnColumnResized: TColumnResized read FOnColumnResized write FOnColumnResized;
  end;

implementation

function TExtendedGrid.MismasColumnas: boolean;
var
  i: integer;
begin
  Result := false;
  i := 0;
  if FListCols.Count <> DataSource.DataSet.Fields.Count then
    Exit;

  while (i <= DataSource.DataSet.Fields.Count - 1) and not Result do
  begin
    if DataSource.DataSet.Fields[i].FieldName = TColumn(FListCols[i]).Field.FieldName then
      inc(i)
    else
      Result := true;
  end;
end;

procedure TExtendedGrid.LinkActive(Value: Boolean);
begin
  inherited;

  if not Value then
    Exit
  else
  begin
    Ok := MismasColumnas;
    FListCols.Clear;
    FListCols.Assign(Self.Columns);

    if Ok then Exit;
  end;
end;

procedure TExtendedGrid.ColWidthsChanged;
var
  i: Integer;
begin
  inherited;

  if Columns.Count <> FListCols.Count then
    Exit;

  for i := 0 to Columns.Count - 1 do
    if Columns.Items[i].Width <> FListCols.Items[i].Width then
      if Assigned(OnColumnResized) then
        OnColumnResized(Self, Columns.Items[i]);

  FListCols.Clear;
  FListCols.Assign(Columns);
end;

procedure TExtendedGrid.ColumnMoved(FromIndex, ToIndex: Integer);
begin
  FListCols.Clear;
  FListCols.Assign(Columns);

  inherited;
end;

constructor TExtendedGrid.Create(AOwner: TComponent);
begin
  inherited;

  FListCols := TDBGridColumns.Create(Self, TColumn);
end;

destructor TExtendedGrid.Destroy;
begin
  FreeAndNil(FListCols);

  inherited;
end;
Seguramente es algo más liado que lo tuyo, pero me interesaba poder pasar un TColumn y, a parte, así podré controlar otras cosillas que tengo en mente

Nos leemos
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


La franja horaria es GMT +2. Ahora son las 19:37:19.


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