DevExpress右键菜单使用

时间:2024-05-20 21:55:41

添加BarManager和popupMenu组建:

 

DevExpress右键菜单使用

 

设置popupMenu组件的Manager属性:

 

DevExpress右键菜单使用

 

右键点击popupMenu主键,点击Customize选项添加菜单:

DevExpress右键菜单使用  DevExpress右键菜单使用  

然后便可添加到鼠标事件中,此处以TreeList为例:

private void treeList1_MouseUp(object sender, MouseEventArgs e)  
{  
    TreeList tree = sender as TreeList;  
    if (e.Button == MouseButtons.Right && ModifierKeys == Keys.None && treeList1.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);  
        }  
  
        if (tree.FocusedNode != null)  
        {  
            popupMenu1.ShowPopup(p);  
        }  
    }  
} 

 

转载于:https://www.cnblogs.com/MuNet/archive/2013/05/02/5736175.html