I have a DataGridView 'DGV_MachinesExclusion' that's bound to a DataTable 'ExcludedMachines'. When manually adding a new row in the DataGridView I use the CellValueChanged event of the DataGridView to trigger the code below.
private void DGV_MachinesExclusion_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
DataRow dr = ExcludedMachines.NewRow();
dr = ((DataRowView)DGV_MachinesExclusion.Rows[0].DataBoundItem).Row;
ExcludedMachines.Rows.Add();
UpdateExlusionList();
}
The result is that it adds two rows. One blank row and one row with the manually added data. The method 'UpdateExclusionList()' just write the DataTable to an XML file. I have used this way of dynamically adding rows succesfully in the past. Can anyone explain why this code adds two rows?
Thx, Thomas