是否有可能以及如何以編程方式選擇標準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,對於混淆抱歉。 –