如何获取行索引或在gridData.SelectItems属性中记录所有项目的位置。
SelectedItems
Contains actual data (ViewModel) from the collection bound to datagrid's ItemSource
. Therefore you can obtain the index in that collection for every item selected.
if its a datagridview on winforms then this would work
List<int> rowIndexs = new List<int>();
foreach (DataGridViewRow item in gridData.SelectedRows)
{
rowIndexs.Add(item.Index);
}
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.