Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 16-07-2003
Angel Angel is offline
Miembro
 
Registrado: may 2003
Ubicación: Alicante, España
Posts: 58
Poder: 22
Angel Va por buen camino
Problemas de Inicialización de un componente

Hola a todos,

Os explico muy por encima lo que quiero hacer, tengo un componente, del cual he creado un TCollection para poder especificar ciertos valores de los campos de una tabla, y resulta que cuando creo el componente, quiero que se me inicialice esa colection con los campos que hay en una tabla. Me parece que no me explico, a ver si con un poco de código lo consigo explicar:

Código:
  { TFieldItem }
  TFieldItem = class(TCollectionItem)
  private
    FName: String;
    FColTitle: String;
    FDefaultSearch: Boolean;
    FSize: Integer;
  protected
    function GetDisplayName: String; Override;
  public
    procedure Assign(Source: TPersistent);
    procedure SetDefaultSearch (Value: Boolean);Virtual;
  published
    property Name: String read FName write FName;
    property ColTitle: String read FColTitle write FColTitle;
    property DefaultSearch:Boolean read FDefaultSearch write SetDefaultSearch;
    property Size: Integer read FSize write FSize;
  end;

  { TFieldList }
  TFieldList = class(TCollection)
  private
    FOwner: TPersistent;
    function GetItem(Index: Integer): TFieldItem;
    procedure SetItem(Index: Integer; Value: TFieldItem);
  protected
  public
    function GetOwner: TPersistent; Override;
    constructor Create(AOwner: TPersistent);
    destructor Destroy; override;
    procedure Add(AName: String; ADefaultSearch:Boolean; AColTitle: String;
                  ASize: Integer);
    procedure Clear;
    property Items[Index: Integer]: TFieldItem read GetItem write SetItem; default;
  published
  end;

  TDBViewer = class(TComponent)
  private
    FDataSet: TDataSet;
    FReturnParams: Integer;
    FReturnValues: array of Variant;
    FFieldDefs: TFieldList;
    FFormTitle : String;
    FFormWidth: Integer;
    FFormHeight:Integer;
    FEditColor: TColor;
    FGridColor: TColor;
    FDataLink: TFieldDataLink;
    function GetDataField: string;
    function GetDataSource: TDataSource;

    procedure SetDataField(const Value: string);
    procedure SetDataSource(Value: TDataSource);

  public
    procedure SetDataSet(Value: TDataSet); virtual;
    procedure SetReturnParams(Value: Integer); virtual;
    function GetDataSet: TDataSet; virtual;
    constructor Create(AOwner : TComponent); override;
    destructor Destroy; override;
    procedure Execute;
    function ReturnParamValues (Param:Integer):Variant;

  published
    property FieldDefs: TFieldList read FFieldDefs;
    property DataSet: TDataSet read GetDataSet write SetDataSet;
    property ReturnParams: Integer read FReturnParams Write SetReturnParams default 1;


    property FormTitle: String read FFormTitle Write FFormTitle;
    property FormHeight: Integer read FFormHeight Write FFormHeight;
    property FormWidth: Integer read FFormWidth Write FFormWidth;
    property EditColor: TColor read FEditColor Write FEditColor;
    property GridColor: TColor read FGridColor write FGridColor;

  end;
Pues bien, lo que quiero es que cuando se cree un DBViewer la propiedad FFieldDefs contenga las columnas que hay dentro del DataSet (eso en tiempo de diseño), pero que cuando se ejecute la aplicación, yo pueda acceder a esos items (y a sus valores, tanto si se han cambiando como si no).

Espero haberme explicado, y gracias a todos
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 04:34:04.


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