日期:2014-05-17 浏览次数:20837 次
private void listView1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
var hitTestInfo = listView1.HitTest(e.X, e.Y);
if (hitTestInfo.Item != null)
{
var loc = e.Location;
loc.Offset(listView1.Location);
// Adjust context menu (or it's contents) based on hitTestInfo details
this.contextMenuStrip2.Show(this, loc);
}
}
}
private void lbc_MouseUp(object sender, MouseEventArgs e)
{
if (_havedo && lbc.SelectedItem != null && e.Button == MouseButtons.Right)
{
int posindex = lbc.IndexFromPoint(new Point(e.X, e.Y));
if (posindex >= 0 && posindex < lbc.Items.Count)
{
lbc.SelectedIndex = posindex;
pm.ShowPopup(Control.MousePosition);
}
}
}