2010-12-03 70 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

相關問題