Insert a Row with a sorted DataGridView
Posted
by Ruben Trancoso
on Stack Overflow
See other posts from Stack Overflow
or by Ruben Trancoso
Published on 2009-11-02T22:09:12Z
Indexed on
2010/05/23
2:00 UTC
Read the original article
Hit count: 408
My DataGridView is bound to the same BindingSource as the Insert Form, and the Name column is sorted. After insert is done, the groupBindingSource.Current is not returning the new inserted DataRowView but the last row in the sort order what makes the Update do nothing.
FormGroup formGroup = new FormGroup();
formGroup .Source = groupBindingSource;
formGroup .setMode(FormGroup.Mode.Insert);
if (formGroup .ShowDialog() == DialogResult.OK)
{
DataRowView drv = (DataRowView)groupBindingSource.Current;
grupoTableAdapter.Update(drv.Row);
}
© Stack Overflow or respective owner