2010-09-21 96 views
0

當第一次加載Form時,是否可以將CurrentRow設置爲DataGridViewnull?我想這樣做,因此我的BindingSource上的CurrentChanged事件不會觸發。使用DataGridView中的CurrentRow

爲了澄清,最初加載Form時,我不想在我的DataGridView中選擇任何行。我只想要BindingSource.CurrentChanged只在用戶選擇一行時觸發。

回答

0

CurrentRow是隻讀的。
我想你應該將CurrentCell設置爲null。

0

爲什麼不設置e.Cancel = true;在事件中取消它?

0

您可以使用this.dataGridView1.ClearSelection();方法清除行選擇。我不知道它是否適合你的情況。

0

嘗試

   foreach(DataGridViewCell Cell datagridview1.SelectedCells) 
       { 
         Cell.Seleted=false; 
       } 

我希望這將解決您的問題。

相關問題