簡體   English   中英

如何將菜單項添加到默認右鍵單擊devexpress樹形列表

[英]How to add a menu item to the default right-click on the devexpress treelist

我有一個DevExpress(版本9.2)TreeList,默認情況下會顯示一個菜單,其中包含排序升序/降序,列選擇器,以及右鍵單擊樹標題時的最佳擬合。

如何在此默認菜單中添加更多選擇?

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


    }

或在菜單項中添加表單加載事件處理程序。 根據需要添加菜單單擊處理程序。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM