I am adding columns to DGV thru code with AllowUserToAddRows = true. In WinForm and Wisej, when the first column is added, it triggers RowAdded event immediately. In Winform, it will continue to add all other columns to the DGV and fires the DefaultValuesNeeded when the NewRow is clicked or entered. But in Wisej, right after adding the first column, it subsequently fires DefaultValuesNeeded right away causing a “Column named Column2 cannot be found” error.
I am using DefaultValuesNeeded to initialize the NewRow with default values. If I want to initialize this row with:
e.Row.Cells[“Column1”].Value = “Washington”; //Column1 is already in the DGV
e.Row.Cells[“Column2”].Value = “DC”;
the second line will fail because Column2 has not been added yet when DefaultValuesNeeded is executed.
Am I missing something? Any workaround for this?
Looks like it’s called too early when the column collection changes when adding the first auto column. Then it’s called a second time when the row collection changes. If you check the number of cells in e.Row you can prevent the error and process the new row only when it’s the good one.
I will log this issue and should be fixed by tomorrow.
Please login first to submit.