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