简体   繁体   English

DataViewGrid-选定的行(未绑定)

[英]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. 例如,表格有20行,用户使用行标题上的鼠标选择第3、4、5、6行。 How can I determine that the selection starts at row 3? 如何确定选择从第3行开始?

You can sort the rows by their index to put them in order. 您可以按行的索引对行进行排序,以将其排序。 A LINQ example that puts them in a list: 一个将它们放在列表中的LINQ示例:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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