我想从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
派生一个新类:
type
TMyTreeColumn = class(TVirtualTreeColumn)
// add your desired properties as needed...
end;
然后从TVirtualStringTree
派生一个新类并重写其虚拟GetColumnClass()
方法:
type
TMyStringTree = class(TVirtualStringTree)
protected
function GetColumnClass: TVirtualTreeColumnClass; override;
end;
function TMyStringTree.GetColumnClass: TVirtualTreeColumnClass;
begin
Result := TMyTreeColumn;
end;