DefaultValuesNeeded Event in DGV

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
0
0

Hi,

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?

Thanks.


 

 

  • You must to post comments
0
0

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.

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Attachment
File Name Size
There are currently no files uploaded.
Maximum number of files 1, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json