0
我有一个DevExpress(版本9.2)TreeList,默认显示一个菜单,其中包含升序/降序排序,列选择器,点击树的标题。如何将菜单项添加到默认右键单击devexpress treelist
我该如何在此默认菜单中添加更多选择?
我有一个DevExpress(版本9.2)TreeList,默认显示一个菜单,其中包含升序/降序排序,列选择器,点击树的标题。如何将菜单项添加到默认右键单击devexpress treelist
我该如何在此默认菜单中添加更多选择?
要添加到默认菜单,您需要使用ShowTreeListMenu操作侦听器并在其中添加行。
Private Sub treeCompany_ShowTreeListMenu(ByVal sender As System.Object, ByVal e As DevExpress.XtraTreeList.TreeListMenuEventArgs) Handles treeCompany.ShowTreeListMenu
' add the ability to expand the nodes in the tree
e.Menu.Items.Add(New DevExpress.Utils.Menu.DXMenuItem("Expand All Nodes", AddressOf ExpandNode))
' make the last item added begin the group so you have a divider
e.Menu.Items(e.Menu.Items.Count - 1).BeginGroup = True
' add the ability to collapse the nodes in the tree
e.Menu.Items.Add(New DevExpress.Utils.Menu.DXMenuItem("Collapse All Nodes", AddressOf CollapseAll))
End Sub
第一加法调用函数ExpandNode()
和第二呼叫CollapseAll()
。
void treeList1_PopupMenuShowing(object sender, DevExpress.XtraTreeList.PopupMenuShowingEventArgs e)
{
DXMenuItem item = new DXMenuItem("New menu item");
e.Menu.Items.Add(item);
}
或者在表单加载事件处理程序中添加菜单项。根据需要添加菜单点击处理程序。
我不认为这是属于treelist属性的对象。 “p”下的唯一操作是PaddingChanged,ParentChanged和PreviewKeyDown。 – Kyra 2010-12-03 21:50:19
我使用v10.2,也许它是新的。它也没有记录在任何地方。我无法找到其他方式来实际影响菜单。也许你有PreparePopupMenu并可以使用它。 – 2010-12-04 00:36:53