views:

174

answers:

1

Hi,

I have a problem using Infragistics UltraTree 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#?

A: 

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.

Jason D