C # Shuffling Rows DataGridView

I have a DataGridView with thousands of records that I added programmatically. In this case, there is no data source. Now I want to shuffle the recordings every time I press the button. How can this be achieved?

+5
source share
2 answers

According to this question, you can use DataGridView.Rows.RemoveAtand DataGridView.Rows.Insertto move rows to an unrelated DataGridView. You can generate a set of random integer indexes to copy, delete, and paste elsewhere in the table to recreate the "shuffle".

0
source

OrderBy (x = > Guid.NewGuid()). Guid . GUID , . , , (, Random (-1, 1)).

+1