DataGridView DefaultValuesNeeded event fires for the first row when Datasource is set

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

Hi guys,

Please have a look at the attached project.

There are three dgvs, bound to the same datasource. They all have AllowUserToAddRow = true.

The top one, has no DefaultValuesNeeded event. The source list is displayed correctly.

The second one has¬†DefaultValuesNeeded event, in which two column values are set. When the dgv Datasource is set, the event fires (incorrecty I suppose — it also fires twice) for RowIndex = 0, and the list is displayed as in the first dgv, but with the two column values of the first row changed by the event.

For the third one, an empty datasource is set, but the event fires again, and instead of having an empty “add new” row, the single row shows up with the two column values set by the event.

I suspect it is a regression.

Best,
Alex

 

  • You must to post comments
0
0

Hi Alex,

fix for WJ-7894 is included in the latest build (1.3.18).

Best regards
Frank

  • You must to post comments
0
0

Hi Alex,

I have missed something very basic: the description of the problem and the labels in the sample. ūüôā I didn’t see that the main issue was that the row index was zero for a grid with more rows. The bug is logged as WJ-7894:¬†DGV may fire DefaultValusNeeded with row index = 0 when binding to list instead of the index of the automatic new row.

The rest of my long answer is still valid.

Best,

Luca

  • Alex Prinias
    yeah, the description and the labels were quite essential :) If you don’t see any errors during editing the new row, I’d be very interested to see what modifications you have made compared to my original project… I keep getting errors. A
  • Luca (ITG)
    I’ll send the changes and the dev build.
  • You must to post comments
0
0

Hi Luca,

Can you mail me the modified project (with the IBindingList – BindingSource)? I just changed the DataSource seetings to = new BindingSource(persons, null) and I keep getting errors in all grids (conversion of the string ” to Int32). Additionally, I keep seeing the incorrect modification of the first row in the middle grid. So, please send me the modified project, I might be missing something very basic…

Thanks,
Alex

  • You must to post comments
0
0

Hi Alex,

I spotted two bugs:

  • The vertical scrollbar is incorrect: WJ-7892
  • The new row shouldn’t be there even with AllowUserToAddRows = true since the source is not an IBindingList. WJ-7893.

Changing the list to an IBindingList (BindingSource) I can see the calls to DefaultValuesNeeded but they all seem correct. I tried the same app in WinForms and the call to DefaultValuesNeeded comes every time you enter the automatic new row. Wisej by design does it differently to avoid updating all the cells when the automatic new row is entered and left, so it calls DefaultValuesNeeded when the automatic new row is created (once).

However, during the creation of the DGV, or assigning the data source, changing the column collection, the automatic new row may get removed and added several times as the table model changes. For example, the when the grid is created, the automatic new row is created (DefaultValuesNeeded is called), when the datasource is assigned all the existing rows are removed, the new rows from the data source are added, and then the automatic new row is created again (DefaultValuesNeeded is called again).

In fact with the test app, if you edit the new row in the first grid (the one without ¬†DefaultValuesNeeded) you get a¬†data error from the combobox column since it cannot convert “” to the index in the Profession list. The other 2 grids instead have the new row initialized correctly.

Best,

Luca

 

 

  • You must to post comments
Showing 4 results
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 5, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json