用TCollectionItem和TCollection,它们可以进行存储。Delphi的Toolbar,TStatusBar都是这样。

解决方案 »

  1.   

    如果不需要在设计时赋值,可以用TList, TStringList, TObjectList存储,然后声明属性及存取方法,以字符串为例:
      private
        FList: TStringList;
        function GetItem(index: Integer): String;
        procedure SetItem(index: Integer; const Value: String);
        function GetCount: Integer;  public
        property Count: Integer read GetCount; // 数目
        property Items[index: Integer]: String read GetItem Write SetItem;function TForm1.GetCount: Integer;
    begin
      Result := FList.Count;
    end;function TForm1.GetItem(index: Integer): String;
    begin
      Result := FList[index];
    end;procedure TForm1.SetItem(index: Integer; const Value: String);
    begin
      Assert( index<=FList.Count ); // 最多为比数目大一个
      if index=FList.Count then
        FList.Add( Value ) // 如果比数目多一个,就增加
      else
        FList[index] := Value;
    end;
      

  2.   

    TList无法把数据存入dfm中,而TCollection可以。