I need help with a DataGridView MultiSelect issue RRS feed

  • Question

  • I have a DataGridView which has MultiSelect set to true.

    I have to toggle a process each time a row is selected and I'm doing that without problem.

    The problem comes when a user selects multiple rows by holding down the shift key. The first row selected toggles when it is first clicked and once again when the last key is clicked, thereby double-toggling the first row clicked. If all rows were "off" and I select row 7 and hold the shift key down then select row 4, row 7 gets toggled "on" then "off" again while rows 6, 5, and 4 get toggled only to "on."

    Is there a good, simple solution to this problem? I've tried looking at the number of rows selected and viewed the selected row list and the sleected row indexes are always presented in a descending order, not the order they were selected.

    Monday, April 8, 2013 11:21 PM


  • Hello,

    In regards to the sort order take a look at the following post Order in DataGridView multiple select. Also perhaps (although not a solution) this might help.

    Dim SelectedRows =
            From T In DataGridView1.SelectedRows.Cast(Of DataGridViewRow)()
            Order By T.Index Ascending

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Tuesday, April 9, 2013 10:46 AM