是否有可能以及如何以编程方式选择标准WinForms数据网格中的非连续行?以编程方式多次选择WinForms DatagridView中的行
foreach (var selectableRowIndex in selectableRowIndices)
{
dataGridView.Rows[selectableRowIndex ].Selected = true;
}
...的工作,但通过
dataGridView.CurrentCell = dataGridView.Rows[underlyingRowIndex].Cells[1];
设置在DataGridView的.CurrentCell房产毕竟其他行均取消选中。
什么是设置当前行/单元格并保持其他行被选中的正确方法?
由于您在谈论'行'属性,我假设您使用'DataGridView'而不是'DataGrid'类。 你使用的代码在这里可以正常工作......你能确认你的'DataGridView'的'MultiSelect'属性设置为'true'吗? – DarkSquirrel42
Multiselect确实设置为true,是的它是一个DataGridView,对于混淆抱歉。 –