如何从 Windows 窗体 datagridview 中删除当前单元格焦点?

Kot*_*tan 1 .net datagridview

如何从 Windows 窗体 datagridview 中删除当前单元格焦点?我有一个包含一些 datagridforms 的对话框,最初我不想选择单元格。实际上在每个网格视图中都选择了单元格 [1,1]

我已经在一些论坛中搜索过,但提供的解决方案不起作用。例如,通常建议设置 CurrentCell = null --> 但这没有效果。有没有其他解决方案,它确实有效;-)?

Elm*_*mex 7

我认为这会起作用:

if (dataGridView.RowCount > 0 && dataGridView.ColumnCount >0)
{
   dataGridView.CurrentCell = this.dataGridView[0, 0];
   this.dataGridView.CurrentCell.Selected = false;
} 
Run Code Online (Sandbox Code Playgroud)


Yul*_*lia 6

dataGridView.ClearSelection();
dataGridView.CurrentCell = null;
Run Code Online (Sandbox Code Playgroud)