简体   繁体   中英

How to get selected index when used to Ctrl+A key to select rows in grid

如何获取行索引或在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.

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