掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
TreeNode を使用するには? (ID:19423)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
TTreeNodes は、オーナーであるTTreeViewなしでは生きていけないからです。 オーナーのTTreeViewなしは、<<想定外>>です(笑) ツリー構造化するなら、それなりのクラスを作るべきとは思いますが、 こちらは、Delphi5までしか知りません。 Delphi6以降であれば、なにかそういったクラスがあるのかもしれませんな。 自分なら、こんな感じでごまかして作ります。 THogeTreeList=class; THogeItem=class(TCollectionItem) protected FChild:THogeTreeList; FHoge1: Integer; FHoge2: String; public constructor Create(aCollection: TCollection); override; destructor Destroy; override; procedure Assign(Source: TPersistent); override; end; THogeTreeList=class(TCollection) protected function GetNode(Index: Integer): THogeItem; procedure SetNode(Index: Integer; Value: THogeItem); public property Node[Index: Integer]:THogeItem read GetNode write SetNode; end; constructor THogeItem.Create(aCollection: TCollection); begin inherited Create(aCollection); FChild:=THogeTreeList.Create(THogeItem); end; destructor THogeItem.Destroy; begin FChild.Free; inherited Destroy; end; procedure THogeItem.Assign(Source: TPersistent); begin inherited Assign(Source); if Source is THogeItem then begin Hoge1:= THogeItem(Source).Hoge1; Hoge2:= THogeItem(Source).Hoge2; end; end; function THogeTreeList.GetNode(Index: Integer): THogeItem; begin Result := THogeItem(Items[Index]); end; procedure THogeTreeList.SetNode(Index: Integer; Value: THogeItem); begin Items[Index].Assign(Value); end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.