ackid32

Is there any way to enable & disable the Treeview nodes

thanks in advance



Re: Windows Forms General Treeview nodes enable & disable

nobugz

What should not happen when a node is disabled





Re: Windows Forms General Treeview nodes enable & disable

.Binny

In the winforms api there is no member within the treeview/treenode to enable/disable a particular treenode.

In .NET framework version 2.0 you can go for a owner drawn TreeNode(setting DrawMode), & paint it accordingly to be shown as enabled\disabled.

Other way would be, you creating a new sublcass of the TreeNode having a Enabled property. Set its forecolor to System.Drawing.SystemColors.GrayText when disabled & to its original forecolr when enabled. some other points that you need to consider is, enabling/disabling checkbox when your treeview's Checkboxes property is set true. changing enabled state of child treenodes etc...





Re: Windows Forms General Treeview nodes enable & disable

ackid32

im using treeview for menu purpose. i want to disable some items in the menu. so any help



Re: Windows Forms General Treeview nodes enable & disable

nobugz

Okay, so you actually want to disable menu items, not tree nodes. That took a mental leap. Implement the AfterSelect event and set the menu items' Enabled property as needed.





Re: Windows Forms General Treeview nodes enable & disable

ackid32

Please understand that i use treeview as menu

the nodes are the menu items

i want to disable some nodes (i.e menu item)

thanks





Re: Windows Forms General Treeview nodes enable & disable

nobugz

Okay, that took another leap. I hope your users can figure this out, TreeView is not an ideal control for this. You can indicate whether or not a "menu item" is enabled by setting the TreeNode.ForeColor property. You'll have to implement "disabled" by code in the AfterSelect event handler.