當第一次加載Form
時,是否可以將CurrentRow
設置爲DataGridView
至null
?我想這樣做,因此我的BindingSource
上的CurrentChanged
事件不會觸發。使用DataGridView中的CurrentRow
爲了澄清,最初加載Form
時,我不想在我的DataGridView
中選擇任何行。我只想要BindingSource.CurrentChanged
只在用戶選擇一行時觸發。
當第一次加載Form
時,是否可以將CurrentRow
設置爲DataGridView
至null
?我想這樣做,因此我的BindingSource
上的CurrentChanged
事件不會觸發。使用DataGridView中的CurrentRow
爲了澄清,最初加載Form
時,我不想在我的DataGridView
中選擇任何行。我只想要BindingSource.CurrentChanged
只在用戶選擇一行時觸發。
CurrentRow是隻讀的。
我想你應該將CurrentCell設置爲null。
爲什麼不設置e.Cancel = true;
在事件中取消它?
您可以使用this.dataGridView1.ClearSelection();
方法清除行選擇。我不知道它是否適合你的情況。
嘗試
foreach(DataGridViewCell Cell datagridview1.SelectedCells)
{
Cell.Seleted=false;
}
我希望這將解決您的問題。