I am trying to display the treeview in readonly mode. That means we shouldn't allow to click on +(plus) sign to expand or collapse nodes. It is always in expanded mode. I have tried with treeview1.enabled property. This property is disabling(fading) the node text. I don't want to disable the text. Is there anyway I can achieve this?
Regards..

Nainil148 reputationPosted Feb 22, 2008, 3:46 PM EST
Hi Nate,
You can handle the BeforeCollapse event of the TreeView control. The second parameter passed in is of type TreeViewCancelEventArgs. The TreeViewCancelEventArgs class contains a Cancel property which you can set to False to disallow any collapse of nodes. Hence the code snippet should be as follows:
private void treeView1_BeforeCollapse(object sender, TreeViewCancelEventArgs e){
e.Cancel = true;
}
Doing above should never allow the user to collapse a node.
Len L25 reputationPosted Feb 23, 2008, 1:38 PM EST
a simple way to do what you want is to put the treeview inside a panel and set the panels Enabled property to false.
Nate7 reputationPosted Feb 25, 2008, 4:17 AM EST
Thanks for your message. I tried with putting Treeview inside the Panel. It didn't work. It disabled the treeview also. The treeview node text is disabled(faded text).
Also tried with BeforeCollapse() but still not working.
Regards..
Nate7 reputationPosted Feb 25, 2008, 8:35 AM EST
Hi Nainil,
BeforeCollapse() event is working. Thank you so much for your help.
Regards..
Nate