日期:2014-05-18  浏览次数:20676 次

怎么将一个ContextMenuStrip判定到一个按钮上?
在线等啊!谢谢了

------解决方案--------------------
if (e.Button == MouseButtons.Right)
{
int posindex = listBox2.IndexFromPoint(new Point(e.X, e.Y));
listBox2.ContextMenuStrip = null;
if (posindex >= 0 && posindex < listBox2.Items.Count)
{
listBox2.SelectedIndex = posindex;
contextMenuStrip1.Show(listBox2, new Point(e.X, e.Y));
}
}
listBox2.Refresh();

形如: