掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Tstrings型のプロパティを作るには? (ID:18912)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
ちゃんとコンストラクタで FList := TStringList.Create; を実行してますか? こんな感じです。 implementation {$R *.dfm} type TMyClass = class(TComponent) private FList: TStrings; procedure SetList(value: TStrings); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; property List :TStrings read FList write SetList; end; constructor TMyClass.Create(AOwner: TComponent); begin inherited; FList := TStringList.Create; end; destructor TMyClass.Destroy; begin FList.Free; inherited; end; procedure TMyClass.SetList(value: TStrings); begin FList.Assign(value); end; var L:TMyClass; procedure TForm1.FormCreate(Sender: TObject); begin L := TMyClass.Create(self); L.List.Add('0000'); L.List.Add('1111'); L.List.Add('2222'); L.List.Add('3333'); end; procedure TForm1.Button1Click(Sender: TObject); begin Caption := L.List[2] end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.