2010-12-03 123 views

回答

1

要添加到默认菜单,您需要使用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()

1
void treeList1_PopupMenuShowing(object sender, DevExpress.XtraTreeList.PopupMenuShowingEventArgs e) 
    { 
     DXMenuItem item = new DXMenuItem("New menu item"); 
     e.Menu.Items.Add(item); 


    } 

或者在表单加载事件处理程序中添加菜单项。根据需要添加菜单点击处理程序。

+0

我不认为这是属于treelist属性的对象。 “p”下的唯一操作是PaddingChanged,ParentChanged和PreviewKeyDown。 – Kyra 2010-12-03 21:50:19

+0

我使用v10.2,也许它是新的。它也没有记录在任何地方。我无法找到其他方式来实际影响菜单。也许你有PreparePopupMenu并可以使用它。 – 2010-12-04 00:36:53

相关问题