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..
NatePosted Feb 25, 2008, 1:35 PM
Hi Nainil,
BeforeCollapse() event is working. Thank you so much for your help.
Regards..
Nate
NatePosted Feb 25, 2008, 9:17 AM
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..
Len LPosted Feb 23, 2008, 6:38 PM
a simple way to do what you want is to put the treeview inside a panel and set the panels Enabled property to false.
NainilPosted Feb 22, 2008, 8:46 PM
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.