Hi,
got a problem with Contextmenu. I got a ListView and want to have the ContextMenu only shown when the user rightclicks an Element
in the Listview. If ther is no element under the mouse cursor no menu shall appear.
The source looks like
private void lstMaterials_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) {
if(e.Button == MouseButtons.Right){
Point p = new Point(e.X,e.Y);
ListViewItem lv = lstMaterials.GetItemAt(p.X,p.Y);
if(lv!=null){
lv.Selected = true;
conMatMenu.Show(lstMaterials,p);
}
}
}
So far so good, menu only appears when a ListViewItem is below the mouse cursor. But if i right click another Item, the menu just
closes. So i have to click twice on the element (once to close it and once to open the context for the new menu). I failed to find
a way to close an already opened ContextMenu before doing the check if an ListViewItem is below the mousecursor.
Any ideas?