How to make a tree structure irreversible?

Using the TreeView control in WinForms, is there a property that can be set to hide the collapse-node icons for each node?

Also, how do I constantly expand all nodes in a TreeView?

+4
source share
3 answers

You need to handle the OnBeforeExpand event and set Cancel to true .

 private void OnBeforeExpand(TreeViewCancelEventArgs e) { e.Cancel = true; } 

Keep in mind that this will prevent the expansion of any node tree.

If you want to hide the "+/-" characters, you must set the ShowPlusMinus property to false .

+3
source

You can try to handle the BeforeCollapse event and set e.Cancel = true , always.

+2
source

You can catch the TreeView.BeforeCollapse event

 private void YourBeforeCollapseEventHandler(object sender, TreeViewCancelEventArgs e) { e.Cancel = true; } 
+1
source

All Articles