Ticket Q258876
Visible to All Users

right click in empty space does not de-select rows

created 15 years ago

When using the winforms grid, if I select a row in a grid, then right-click on empty space (below the rows, where additional rows would otherwise be), the ContextMenu is opened however the rows stay selected, so the context menu will operate on the selected rows (when it uses GetSelectedRows() to find out what was selected).
Doing the same thing in Windows Explorer behaves differently: selecting a file & right-clicking in empty space causes the selected file to be de-selected, and the context menu which shows is related to the empty space (not the file which is now de-selected).
The second of these is the behavior I need, so that after a right-click fires, what remains selected is relative to where the right-click occurred.
Is there a setting in the grid, which causes the selected row to be de-selected if empty space is clicked (as it is in windows explorer)?

Show previous comments (3)

    Thanks Nick, that helps, but it still has the same behavior which I am trying to avoid.
    When I run the sample project and right-click in the empty space below the rows, the currently selected row in the grid retains focus.
    I can check for hitInfo.HitTest == EmptyRow, however how to I remove focus from a row? That is, make the grid such that no rows are selected/focused?

    DevExpress Support Team 15 years ago

      Hi Mark,
      The XtraGrid always has a focused row and it cannot be deselected. You can try to visually dim down the focused row as shown in the Is it possible to set up the grid to have no focused row? article. However, in my opinion, an easier solution would be displaying a different context menu for the empty area. This menu should not contain row related commands which are available from your context menu for rows.
      Thanks,
      Nick
      --------------------
      Check if Search Engine is able to answer questions faster than I do!

        Thanks

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.