开发者

Working with the CurrentRow in a DataGridView

开发者 https://www.devze.com 2023-01-17 11:04 出处:网络
Is there way to set CurrentRow in a DataGridView to null when a Form is first loaded? I want to do this so the CurrentChanged event o开发者_如何学运维n my BindingSource does not fire.

Is there way to set CurrentRow in a DataGridView to null when a Form is first loaded? I want to do this so the CurrentChanged event o开发者_如何学运维n my BindingSource does not fire.

To clarify, when the Form is initially loaded, I don't want any rows to be selected in my DataGridView. And I want BindingSource.CurrentChanged to fire only when the user selects a row.


CurrentRow is readonly.
I think you should set the CurrentCell to null.


Why don't you set e.Cancel = true; in the event to cancel it?


You can clear the row selection using this.dataGridView1.ClearSelection(); method. I don't know whether it is work with you scenario or not.


Try

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

i hope this will solve your problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消