将 CollectionItem 的属性添加到后代组件
Adding properties to a CollectionItem to a descendant component
我想从 TVirtualStringTree
创建一个后代组件并向 Columns
集合添加更多属性。
TVirtualStringTree
的实际结构是:
+ Header (TVTHeader)
|+ Columns (TVirtualTreeColumns)
|+ CollectionItem (TVirtualTreeColumn)
|- Text
|- Width
|+ Options
|- CheckBox
|- ... Here under [CollectionItem] I would like to add some more properties
请大家支持一下这个话题。谢谢!
从 TVirtualTreeColumn
派生一个新的 class:
type
TMyTreeColumn = class(TVirtualTreeColumn)
// add your desired properties as needed...
end;
然后从 TVirtualStringTree
派生一个新的 class 并覆盖它的虚拟 GetColumnClass()
方法:
type
TMyStringTree = class(TVirtualStringTree)
protected
function GetColumnClass: TVirtualTreeColumnClass; override;
end;
function TMyStringTree.GetColumnClass: TVirtualTreeColumnClass;
begin
Result := TMyTreeColumn;
end;
我想从 TVirtualStringTree
创建一个后代组件并向 Columns
集合添加更多属性。
TVirtualStringTree
的实际结构是:
+ Header (TVTHeader)
|+ Columns (TVirtualTreeColumns)
|+ CollectionItem (TVirtualTreeColumn)
|- Text
|- Width
|+ Options
|- CheckBox
|- ... Here under [CollectionItem] I would like to add some more properties
请大家支持一下这个话题。谢谢!
从 TVirtualTreeColumn
派生一个新的 class:
type
TMyTreeColumn = class(TVirtualTreeColumn)
// add your desired properties as needed...
end;
然后从 TVirtualStringTree
派生一个新的 class 并覆盖它的虚拟 GetColumnClass()
方法:
type
TMyStringTree = class(TVirtualStringTree)
protected
function GetColumnClass: TVirtualTreeColumnClass; override;
end;
function TMyStringTree.GetColumnClass: TVirtualTreeColumnClass;
begin
Result := TMyTreeColumn;
end;