I have a ListView with some items. The ListView has some group defined, some column, and some items are added. The ListView has set also the ContextMenu.
On Opening event of the ContextMenu, I shall check whether the context menu was opened on a ListView item. So, I did:
private void CtxMenuProcess_Opening(object sender, CancelEventArgs e)
{
ContextMenuStrip ctxMenuStrip = (ContextMenuStrip)sender;
ListViewHitTestInfo hitTestInfo = LstViewAdminApp.HitTest(LstViewAdminApp.PointToClient(Control.MousePosition));
if (hitTestInfo.Item != null) {
//....
}
}
Sadly, the hit doesn't happen.
I feel that the coordinates of the ctxMenuStrip are the wrong ones, but I tried a lot of "variants" without success, and the documentation of ListView.HitTest is very poor.
Anybody can help me?
Further investigation doesn't bring any solution. I'm starting to suspect about ListView control initialization. Here is the non default properties I have set:
- Activation = OneClick
- Columns = Colum[3]
- ContextMenuStrip = ContextMenu
- Dock = Fill
- FullRowSelect = true
- GridLines = true
- Groups = Group[3]
- HideSelection = false
- LabelWrap = false
- Sorting = Ascending
- View = Details