I have a DataGridView and a number of controls (for editing) all bound to a BindingSource. Everything works as expected - clicking on an entry in the DataGridView causes the bound edit controls to display and edit the selected item. What I want to be able to do is have newly created items be automatically selected in the DataGridView, with the edit controls also bound to the newly created data. To do this, I have implemented a handler for DataGridView.RowsAdded, like so:
private void dataGridViewBeasts_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
// Force newly created items to be selected
dataGridViewBeasts.Rows[e.RowIndex].Selected = true;
}
This works superficially, with the newly created items being selected in the DataGridView. However, the edit controls persist in referring to the item that was selected prior to creating a new item. How can I encourage them to point to the newly selected item?