我正在尝试制作一个带有通知图标的 contextMenuStrip,但我无法将此上下文的位置放在鼠标位置上方。它显示在相同位置的鼠标private void ntfy2_MouseClick(object sender, MouseEventArgs e){
if (e.Button == MouseButtons.Right)
{
contextMenuStrip1.Show(Cursor.Position.X, Cursor.Position.Y); //Show at Postion Mouse
}
}
1 回答
Cats萌萌
TA贡献1805条经验 获得超9个赞
这段代码对您有帮助吗?
private void ntfy2_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
var relativeClickedPosition = e.Location;
var screenClickedPosition = (sender as Control).PointToScreen(relativeClickedPosition);
contextMenuStrip1.Show(screenClickedPosition);
}
}
- 1 回答
- 0 关注
- 146 浏览
添加回答
举报
0/150
提交
取消