日期:2014-05-17 浏览次数:21241 次
private void listView_Route_MouseClick(object sender, MouseEventArgs e)
{
ListViewItem lvi = listView_Route.GetItemAt(e.X, e.Y);
if (lvi != null && e.Button == MouseButtons.Right)
{
this.contextMB_ForRoute.Show();
}
}
private void listView_Route_MouseUp(object sender, MouseEventArgs e)
{
if (MouseButtons.Right == e.Button)
{
if (listView_Route.GetItemAt(e.X, e.Y) == null)
{
// 移除绑定右键菜单
listView_Route.ContextMenu = null;
}
}
else
{
// 移除绑定右键菜单
listView_Route.ContextMenu = null;
}
}
private void listView_Route_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
// 遍历数据
foreach (ListViewItem item in listView_Route.SelectedItems)
{
// 绑定右键菜单
this.contextMB_ForRoute.Show();
}
}