How to add nodes to FireMonkey's TreeView at runtime
I think we are all learning at this point...
But from what I have seen the TTreeView use the principle that any control can parent another control.
All you need to do is set the Parent
Property to get the item to show up as a child.
var
Item1 : TTreeViewItem;
Item2 : TTreeViewItem;
begin
Item1 := TTreeViewItem.Create(Self);
Item1.Text := 'My First Node';
Item1.Parent := TreeView1;
Item2 := TTreeViewItem.Create(Self);
Item2.Text := 'My Child Node';
Item2.Parent := Item1;
end;
Because of this you can do things never possible before, such as placing any control in the TreeView. For example this code will add a button to the area used by Item2, and the button won't be visible until the Item2 is visible.
Button := TButton.Create(self);
Button.Text := 'A Button';
Button.Position.X := 100;
Button.Parent := Item2;