如果您使用ContextMenu并使用带有偏移量的.Show(Control, Point)重载,您应该让菜单显示:
if (e.Button == MouseButtons.Right)
{
// build a new ContextMenu with some menu items, let's use copy and paste
ContextMenu ctxRightClick = new ContextMenu(new MenuItem[]
{
new MenuItem("Copy"),
new MenuItem("Paste")
});
// as per the documentation, the Point used by .Show is relative to the control you pass in so we calculate an offset from the mouse position
int xOffset = Cursor.Position.X - myForm.Location.X;
int yOffset = Cursor.Position.Y - myForm.Location.Y;
// now show the context menu as a child of myForm at the specified offset
ctxRightClick.Show(myForm, new Point(xOffset, yOffset));
}