我有两个DataGridView,当我点击其中一个时,我希望取消选中第二个DataGridView中的所有选择项,我尝试了这个,但是没有起作用:
firstItemsDataGridView.ClearSelection();
firstItemsDataGridView.CurrentCell = null;
无法工作,
firstItemsDataGridView.ClearSelection();
if (firstItemsDataGridView.Rows.Count > 0)
firstItemsDataGridView[1, 0].Selected = true;
firstItemsDataGridView.CurrentCell = null;
firstItemsDataGridView.ClearSelection();
foreach (DataGridViewRow item in firstItemsDataGridView.Rows) {
item.Selected = false;
foreach (DataGridViewCell itemCell in firstItemsDataGridView.Columns) {
itemCell.Selected = false;
}
}
无法工作。
firstItemsDataGridView.Rows[0,-1].Selected = true;
也不起作用。
我已将选择模式设置为整行选择,但我不知道如何实现我的目标。
非常感谢!
firstItemsDataGridView
是期望的网格吗?您是否再次分配了数据源? - V4VendettaCurrentCell=null
应该可以解决问题,但是这样网格中的数据如何显示/添加呢? - V4Vendetta