I really don't know what to search so I'll just ask this:
I have a context menu strip linked to a listview,
what I need is that when I right click to a highlighted variable in the grid list view, the menu for items will be displayed, and when I right click to an empty grid, the grid settings will be displayed.
How can I achieve this?
I doubt the user will appreciate your approach; you plan to display 2 different menus from the same action - a click. It may not be apparent how to get one menu or the other. Further, it is not clear why the "Settings" or main menu would ever need to be hidden from them.
Rather than 2 menus, why not 1 menu with 2 submenus, to make it easy to find them?
The LV will show an assigned menu on its own, but if you have 2, you may want/need to display it manually, which is shown. By using the
MouseUp
event the LV has already reacted toMouseDn
and changed the selected item. The only thing that varies menu-wise is whether theItemMenu
is enabled or not.Clicking on an empty area deselects an item. Barring a button to do the same, it is hard to deselect an item because the empty area can get be almost nonexistent:
Only the orange-ish area is empty grid, add one more item to fill in the bottom and cause a scroll bar and there is none. This is partly why a separate menu and special set of conditions may not be a good idea.