开发者

How to make context menu as non selectable when the usercontrol is active

I am having a context menu displayed when i right click on a node of a treeview. Suppose开发者_StackOverflow社区 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.


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


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..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜