C# DEV 右鍵出現菜單


 

1 向工作區拖入一個DevExpress.XtraBas.Barmanager控件,拖入一個DevExpress.XtraBas.PopupMenu控件。

2 PopupMenu控件設定Manager屬性是剛才拖入的Barmanager名稱,在PopupMenu控件右擊設定“Customise”,設定具體菜單

3 樹右擊菜單的代碼

        /// <summary>
        /// 右擊節點出現的菜單
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeDistrictInfo_MouseUp(object sender, MouseEventArgs e)
        {
            TreeList tree = sender as TreeList;
            if ((e.Button == MouseButtons.Right) && (ModifierKeys == Keys.None)
                 && (treeDistrictInfo.State == TreeListState.Regular))
            {
                Point p = new Point(Cursor.Position.X, Cursor.Position.Y);
                TreeListHitInfo hitInfo = tree.CalcHitInfo(e.Location);
                if (hitInfo.HitInfoType == HitInfoType.Cell)
                {
                    tree.SetFocusedNode(hitInfo.Node);
                    popupMenu1.ShowPopup(p);
                }
            }
         } 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM