I can't found any sample in the online documentation, or in the demos included with Delphi XE2, for adding nodes to a FMX.TreeView.TTreeView
control at runtime. So, how can I add, remove, and traverse nodes of a FireMonkey 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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With