Ticket Q528551
Visible to All Users

xtragrid gridview loses row selection when displaying context menu against a row that is outside of the selected rows

created 11 years ago

I am using a regular gridview to display data from dataset

I select multiple rows using the row header. I then right click against a row that is NOT within the selected rows and the focused row moves to the row that was right-clicked and loses the selection against the originally selected rows. This is different to the windows.forms.datagridview behaviour and I need to keep the rows selected. I have noticed that if I select multiple rows and right click against any one of those rows then the row selection is kept, which is fine but that is not what I need to do.
I am handling PopupMenuShowing event and display a popupmenu. I thought it might be because I was using popupmenu instead of using DXMenuItem but I found a sample that was using that and it still behaves in the way that I don’t want it to.
http://www.devexpress.com/Support/Center/Question/Details/Q388517
run this sample
select rows 0,1 and right-click on row 3
the focused row is now row 3, I don’t want the focus to change, I want to be able to invoke the context menu on row 3 and keep rows 0,1 selected

If it helps, to explain why I need to do this, I want to be able to select items and then click on another item and say “group selected items with the item I have just right-clicked on”

Really hoping we can find a solution for this one. I don’t really want to go down the road of using checkmarks to select items as it is converting an existing application that uses windows.forms compoenents and I want to keep functionality as close as possible to the original

Show previous comments (1)
DevExpress Support Team 11 years ago

    Hello,
    I have created a sample which demonstrates how to keep row selection when you right-click an unselected row. Please try this solution and inform us about your results. The main idea is to use the GridView.GetSelectedRows and GirdView.SelectRow methods.
    We are looking forward to your reply.

      hi alexey, thanks for the solution and the interim update to say it was in progress.
      i did actually put something together myself that did roughly teh same thing but i wanted to see what you guys could come up. Your solution is slightly more polished than mine and it looks to be working well.
      i cant see the buttons to mark as solution

      DevExpress Support Team 11 years ago

        Hello,
        I am glad to hear that my assistance was helpful to you. Feel free to contact us if you have further questions.
        I must note that you cannot mark this comment as a solution since it is a comment, not an answer. For now, I have moved this comment to the Answer section. You can mark the answer as a solution.

        Answers approved by DevExpress Support

        created 11 years ago (modified 11 years ago)

        Hello,
        I have created a sample which demonstrates how to keep row selection when you right-click an unselected row. Please try this solution and inform us about your results. The main idea is to use the GridView.GetSelectedRows and GirdView.SelectRow methods.
        We are looking forward to your reply.

          Comments (2)

            thanks, has gone live today and seems to be working so far

            DevExpress Support Team 11 years ago

              Hello,
              We are glad to hear that the issue has been resolved. Feel free to contact us if you have any further questions.

              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.