简体   繁体   中英

DataViewGrid - selected rows (unbound)

I can get the collection of selected rows but I cannot find a way to determine which is the first selected row. Eg the table has 20 rows, the user selects rows 3,4,5,6 using the mouse on the rowheaders. How can I determine that the selection starts at row 3?

You can sort the rows by their index to put them in order. A LINQ example that puts them in a list:

    Dim orderedList As List(Of DataGridViewRow) = (From row As DataGridViewRow In DataGridView1.SelectedRows Select row Order By row.Index).ToList

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM