怎样控制contextMenuStrip在特定区域弹出?
如题。
------解决方案-------------------- private void frmTest_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
if (e.X > 100 && e.Y > 100)
{
this.ContextMenuStrip = contextMenuStrip1;
}
else
{
this.ContextMenuStrip = null;
}
}
}
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
Point t = this.PointToClient(Cursor.Position);
if (t.X < 150 || t.Y < 150)
{
e.Cancel = true;
}
}
这回应该可以了 ,具体的坐标你自己改下吧