Creating your own component based on TreeView (problem with TTreeNode)

just need o to access my custom TreeView with this:

MyTreeView1.Selected.MyOwnProperty := 'something';

So, all I want to do is make the same component as the TreeView, but + I need to add my own property to all TreeNodes TreeView.

If I can ask again, can someone explain to me how to use the “TTreeNodes data property to point to an object”? Can someone explain how to store some information in it (for example, name and age) and how to get this information from the selected TTreeNode?

+3
source share
3 answers

, XE TTreeView, OnCreateNodeClass TTreeNodes.

:

type
  TMyTreeNode = class (TTreeNode)
  //
  end;

procedure TMyForm.OnCreate(Sender: TObject);
begin
  MyTreeView.OnCreateNodeClass := OnCreateNodeClass;
end;

procedure TMyForm.OnCreateNodeClass(Sender: TCustomTreeView; 
  var NodeClass: TTreeNodeClass);
begin
  NodeClass := TMyTreeNode;
end;

TTreeView Selected, node.

+9

TTreeNodes , , .

, .

+1

, , - Items.

0

All Articles