我现在自写一组件,想在组件上双击就弹出框并输入一列表信息。这些信息是组件的设计信息。要保存在组件上的。结构如下:
TDataFields=class
  private
    DataFields:TList; //里面指针指向一个结构。
  public
    。
end;
组件:
TFastSearch = class(TComponent)
  private
 public
    { Public declarations }
    DataFields:TDataFields;
  published
    property test:TDataFields read DataFields write DataFields;
end;
现在我都作好了,双击组件都可有数据输入。但是运行时却无设计时的数据出现。请问高手这是作么回事。我的DataFields里的数据是new来的。就是new过来的数据无法保存。现在郁闷死了。

解决方案 »

  1.   

    谢谢各位,我刚把TDataFields继承自TCollection已使得数据得已保存,基本达到组件的要求,但是不知作成像dbgrid的columns编辑器里右击菜单时怎么自已添加项目如DBGrid中的Add all fields等。
    我现在的部份代码如下:
      TDataField = class(TCollectionItem)
      private
        FTableName:string;
        FFieldName:string;
        FDisplayName:string;
        FDataType:TFieldType;
      public
        procedure Assign(Source: TPersistent); override;
        constructor Create(Collection: TCollection); override;
      published
        property TableName:string read FTableName write FTableName;
        property FieldName:string read FFieldName write FFieldName;
        property DisplayName:string read FDisplayName write FDisplayName;
        property DataType:TFieldType read FDataType write FDataType;
      end;  TDataFields=class(TCollection)
      private
        FOwner: TPersistent;
        procedure Update(Item: TCollectionItem); override;
      protected
        function GetOwner: TPersistent; override;
      public
        function Add():TDataField;
        constructor Create(AOwner: TPersistent);
        function Owner: TPersistent;
      end;