开发者

specific context menu per UltraTreeNode

I have a problem using Infragistics UltraTr开发者_开发知识库ee control. I need a way to add a specific context menu to an UltraTreeNode. I saw that there is a contextMenu property for the UltraTree, but I need a unique one per each node.

what is the best way for doing this in C#?


I've recently had to do this with a regular TreeView. Since infragistics.UltraTreeNode has a context menu just like the regular TreeNode, I'm guessing the technique will be the same.

Here's how I did it:

Step 1. Assign the context menu of interest to each node that should recieve it. This should be done while populating tree nodes.

Step 2. Intercept the Opening event on the context menu(s)

Step 3. Rebuild the contents of the menu in the "contextMenu_Opening" event handler. Only do this for a context menu object that will be shared among different node types. You can also add all items you want to the menu, up front on the treeview or containing controls construction, then hide or show them through the Visible property. This is really a matter of personal preference at this point.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜