当第一次加载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;
}
我希望这将解决您的问题。