Select newly added Row - DataGridView and BindingSource

前端 未结 5 1658
眼角桃花
眼角桃花 2020-12-11 08:01

I\'m adding a new Row to a BindingSource that is Bound to a DataGridView

source.AddNew();

After this, use BindingSource to get the newly ad

5条回答
  •  醉话见心
    2020-12-11 08:48

    Use the events from the DataGridView like this for this task:

    private void RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
    {
        this.Rows[e.RowIndex].Selected = true;
    } 
    

    That marks the newly added row as the selected.

提交回复
热议问题