I have a ListView with ViewStyle = vsReport and two popup menus:
- Column popup menu, which I want to open when user right-clicking the header bar
- Item popup menu, must open when the user right-clicking any list item/subitem or whitespace below items.
What is the most correct way to show that menus? Which events should I handle?
The problem is when I set ListView.PopupMenu property, the popup menu appearing after right-clicking any point in ListView’s client rectangle.
When I handle ListView.OnColumnRightClick event, if fires only after clicking on column header, excluding free space of the header bar (on the right of columns).
Event LisView.OnMouseUp fires only after right-clicking on whitespace below items.
You don’t have to use the
PopupMenuproperty of the listview, leave it unset and you can attach a handler toOnContextPopupevent and launch whatever popup menu you’d like depending on the position. Example: