2010-06-15 43 views
1

如何從Windows窗體datagridview中刪除當前單元格焦點? 我有一個對話框與一些datagridforms,最初我不想有一個單元格選擇。 實際上在每個gridview中單元格[1,1]被選中如何從Windows窗體datagridview中刪除當前單元格焦點?

我已經在某些論壇中搜索過,但提供的解決方案不起作用。 例如,經常建議設置CurrentCell = null - >,但這不起作用。 有沒有其他的解決方案,這真的有效;-)?

回答

1

我認爲這將工作:

if (dataGridView.RowCount > 0 && dataGridView.ColumnCount >0) 
{ 
    dataGridView.CurrentCell = this.dataGridView[0, 0]; 
    this.dataGridView.CurrentCell.Selected = false; 
} 
1
dataGridView.ClearSelection(); 
dataGridView.CurrentCell = null; 
相關問題