DevExpress RibbonControl组件实现右键弹出菜单(PopupMenu)
DevExpress RibbonControl组件实现右键弹出菜单(PopupMenu)DevExpress RibbonControl组件右键弹出菜单效果:
实现步骤:
在窗体拖放一个弹出菜单(PopupMenu)组件,点右键“Run Designer” 打开弹出菜单的设计器。
给Ribbon Control绑定一个MouseUp事件。
MouseUp事件源码:
C# Code: private void ribbonControl1_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
//有窗体标题,设置Y轴偏移量
if (this.FormBorderStyle != FormBorderStyle.None)
{
Point p = e.Location;
p.Y += 22;//弹出菜单的位置刚好在光标位置
popupMenu1.ShowPopup(p);
}
else
{
popupMenu1.ShowPopup(e.Location);
}
}
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761