每个 UltraTreeNode 的特定上下文菜单

发布于 2024-08-13 00:42:59 字数 159 浏览 9 评论 0原文

我在使用 Infragistics UltraTree 控件时遇到问题。 我需要一种方法将特定的上下文菜单添加到 UltraTreeNode。 我看到 UltraTree 有一个 contextMenu 属性,但我需要每个节点都有一个唯一的属性。

在 C# 中执行此操作的最佳方法是什么?

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#?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自由如风 2024-08-20 00:42:59

我最近不得不使用常规的 TreeView 来完成此操作。由于 infragistics.UltraTreeNode 有一个上下文菜单,就像常规的 TreeNode 一样,我猜测该技术将是相同的。

我是这样做的:

步骤 1. 将感兴趣的上下文菜单分配给每个应该接收它的节点。这应该在填充树节点时完成。

步骤 2. 拦截上下文菜单上的 Opening 事件

步骤 3. 在“contextMenu_Opening”事件处理程序中重建菜单的内容。仅对将在不同节点类型之间共享的上下文菜单对象执行此操作。您还可以将所需的所有项目添加到菜单、树视图或包含控件构造的前面,然后通过 Visible 属性隐藏或显示它们。目前这确实是个人喜好问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文