在DataGridView中使用CurrentRow

时间:2010-09-21 09:56:09

标签: winforms datagridview

首次加载CurrentRow时,是否可以在DataGridViewnull设置Form?我想这样做,因此CurrentChanged上的BindingSource事件无法触发。

为了澄清,最初加载Form时,我不希望在DataGridView中选择任何行。我希望BindingSource.CurrentChanged仅在用户选择一行时触发。

4 个答案:

答案 0 :(得分:0)

CurrentRow是只读的。
我认为你应该将CurrentCell设置为null。

答案 1 :(得分:0)

为什么不在事件中设置e.Cancel = true;取消它?

答案 2 :(得分:0)

您可以使用this.dataGridView1.ClearSelection();方法清除行选择。我不知道它是否适用于你的场景。

答案 3 :(得分:0)

尝试

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

我希望这能解决你的问题。