Jump to content

joachimd

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

3 Neutral

Technical Information

  • Delphi-Version
    Delphi 10.3 Rio
  1. joachimd

    How to get data from class to TVirtualStringTree?

    no, because my events are ways simpler 😉 btw: I use very seldom the "RAD things" ... setting all required properties and event handlers in code looks awful at first, but IMHO it results in a clearer structure of your code. I'd love to see Delphi creating code instead of DFM files (like C# does). That would make things even more simple.
  2. joachimd

    How to get data from class to TVirtualStringTree?

    Correct. My component only has a few (required) Events and Properties, but VST events are not mapped to the outside.
  3. joachimd

    How to get data from class to TVirtualStringTree?

    sure ... it's no big deal 😉 I only have two columns for this viewer: First is the caption, second the ID (for Debug purposes, usually not displayed). procedure TAppListViewer.treeviewGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: string); var data: PSuperNode; begin try data := treeview.GetNodeData(Node); case Column of 0: CellText := data.obj.Caption; 1: CellText := ID2String(data.obj.ID); //btw: it's TGUID, but I leave it open for other datatypes end; except end; end; BTW: You can also define a function in your 'IAppListItem" interface to get the string your need (e.g. function GetText(column: integer): string)
  4. joachimd

    How to get data from class to TVirtualStringTree?

    For such purposes I've written my own component, derived from TWinControl. It contains a TVirtualStringTree and implements all methods required to run it. For the outside world, I've implemented my own methods and properties. Within the implementation part of that unit, I've defined a Node record being used for all data handling. This record contains an implementation of a an interface: interface type TAppListViewer = class(TWinControl) //... implementation type PSuperNode = ^TSuperNode; TSuperNode = record obj: IAppListItem; end; //... IAppListItem iss defined in another unit: IAppListItem=interface ['{CA2770B8-8A4B-4F52-AE6F-5F55E45C6014}'] procedure SetID(const aValue: TIDType); function GetID(): TIDType; property ID:TIDType read GetID write SetID; procedure SetCaption(const aValue: string); function GetCaption(): string; property Caption:string read GetCaption write SetCaption; procedure SetParent(const aValue: IAppListItem); function GetParent(): IAppListItem; property Parent:IAppListItem read GetParent write SetParent; function GetChildren(): TAppList; property Children:TAppList read GetChildren; procedure AddChild(aChild: IAppListItem); procedure RemoveChild(aChild: IAppListItem); //... end; My component has a property getting one such an item (the root) and all children of it. Setting it will cause a rebuilt of the tree. property AppList:IAppListItem read FAppList write SetAppList; HTH Joachim
×