如何在datagridview c#中移动我所在行中的选定内容

本文关键字:datagridview 移动 | 更新日期: 2023-09-27 17:59:57

我尝试在Load and Shown事件中调用dataGridView.ClearSelection();,它只是隐藏选择标记,但第一行还是被选中了?

如何在datagridview c#中移动我所在行中的选定内容

尝试将当前单元格设置为null:

protected override void OnShown(EventArgs e) {
  base.OnShown(e);
  dataGridView.ClearSelection();
  dataGridView.CurrentCell = null;
}

试试这个:

private void dataGridView_DataBindingComplete(object sender,  DataGridViewBindingCompleteEventArgs e)
{
   dataGridView1.Rows[0].Selected = false;
}