I already searched for a solution on this topic. However, I was unable to find one. I trying to implement the solution answer for this question, however when adding a new row to the datagrid, I get "System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection.'" error. after the new row was inserted and the program returned to the previously selected row before inserting a new value.

private void Datagrid_Registro_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
{
Registro.RegistroItems row =(Registro.RegistroItems)Datagrid_Registro.SelectedItems[0];

textbox_DocIdentidad.Text = row.DocumentoIdentidad;
comboBox_Ubicaciones.SelectedItem = row.AreaDestino;
textbox_CarnetAsignado.Text = row.CarnetAsignado;
}
0

There are 0 best solutions below