Partially collapsed treeview lazarus / 31-LCL ---------------------------------------------------------------------- teresa · 2020-11-25 04:54 (I know I had this working 18 months ago but I forget how, don't have access to the code any more) I have a TFreeview, which has two levels of nodes: people, and their children, like this Adam ....Adam1 ....Adam2 Ben ...Ben1 Charlotte Denis    Den1 ...den2 I want the treeview to behave in two ways:    -  1) when loaded to display just the top level nodes: Adam, Ben, Charlotte Denis.    -  2) Then when (double or single-) clicking one of those, to expand just that node  Optionally, to also collapse any node that is already expanded, but I can live without that bit. Some mix of properties and options solved this, but I can't find it now. Any ideas? Teresa ---------------------------------------------------------------------- egsuh · 2020-11-25 07:27 I think what you want is the default behavior of treeview unless you set AutoExpand = true. ---------------------------------------------------------------------- teresa · 2020-11-25 08:27 Thanks, but if I st autoexpand false, the tree loads with only the root node visible. Teresa ---------------------------------------------------------------------- wp · 2020-11-25 08:36 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);var  node: TTreeNode;begin  node := TreeView1.Items.AddChild(nil, 'Adam');  TreeView1.Items.AddChild(node, 'Adam1');  TreeView1.Items.AddChild(node, 'Adam2');   node := TreeView1.Items.AddChild(nil, 'Ben');  TreeView1.Items.AddChild(node, 'Ben1');   node := TreeView1.Items.AddChild(nil, 'Charlotte');   node := TreeView1.Items.AddChild(nil, 'Denis');  TreeView1.Items.AddChild(node, 'Denis1');  TreeView1.Items.AddChild(node, 'Denis2');  TreeView1.Items.AddChild(node, 'Denis3');end; ---------------------------------------------------------------------- teresa · 2020-11-25 20:10 Oh I see what has happened. This code I'm working with has a labeled "root" node, which it shouldn't have. Removing that makes things tidier and working. Thanks for your help.