How do I control the position of the context menu when it is invoked via the keyboard?
Normally, the context menu will be shown at the center of the control when the keyboard is used to invoke the context menu of a control (Shift+F10, for example). You can customize the location as follows.
- Override WndProc in the grid and check if the Message.Msg is
- If so, check if the Message.LParam is -1, which means this was due to a
keyboard message as opposed to the user right-clicking the mouse.
- Now, call the associated ContextMenu’s Show method explicitly at the
selected row position.
- Make sure NOT to call the base class after showing the menu explicitly.