views:

31

answers:

2

I am having a context menu displayed when i right click on a node of a treeview. Suppose my treeview is as follows

Root |->some.txt |-> Child(For some.txt) |-> Child1(child for Child)

If i right click on Child1 i will have an option as AddNew. If the user selects i will show a user control form for the user displayed in a panel.

What i need is if the user selects the option as Child1 and if the user control is active and when the user again right clicks on Child1 i would like to make the context menu as non-selectable field. Can any ine tell how to do.

A: 

Are you using the Winforms treeview or Asp.net treeview any third party usercontrol ? Whatever be the case, you should be having UserId stored somewhere inside the usercontrol. So when the user click on the child node, check whether the UserId of the Node and the UserId inside the usercontrol is same. If they match then disable the option.

Please revert back, if the above workaround doesn't do the trick for you..

Siva Gopal
I am using Winforms treeview
Dorababu
+1  A: 

Any modifications as to the selectability of ContextMenu Items depending on a scenario can be done in the Opening event of the ContextMenu.

• Make sure you have a way of determining whether the usercontrol is visible (flag, Visibility, check for != null...whatever is appropriate in your situation)

• define an opening handler for your contextmenu

• in the opening handler, check if control is visible (see point 1)

• if so, set the menu item's enabled status to false, otherwise to true.

HTH

Sebastian Edelmeier