Data Grid View Add New Row

Answered
0
0

This code used to work prior to version 2.2.

I found when adding a new row directly to a DGV it was not adding it to the bound data table so I had to programatically add the data to the table using the code below

if (Adding)
{
//Underlying datable does not contain new row so we have to add it
DataRow NR = dtTest.NewRow();
for (int j = 0; j < dgvTest.Columns.Count; j++)
{
NR[j] = dgvTest[j, e.RowIndex].Value;
}
dtTest.Rows.Add(NR); //Adds two rows to data table why?
dtTest.Rows[e.RowIndex +1].AcceptChanges();
dtTest.RejectChanges(); //removes duplicate – Fails here now – workaround to remove extra row if commented out two rows added
dtTest.Rows[bsTest.Position].SetAdded();
dm.Update(dtTest, “updEmps”, “”, 46);
}

Thanks for your help

  • You must to post comments
Best Answer
0
0

You can’t code a DGV in the same way that was required for VWG!

Apologies for wasting your valuable time

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.