DGV Add new

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

Hi,

Tiago, your experience here will be invaluable….

I have a DGV with AllowUserToAddRows = true and EditMode = OnEnter and saving to my db on RowLeave. I go to the last empty line, it opens up TextBox for insertion, then I regret it and move the cursor up. The RowLeave event fires and it goes on to save to the db. The problem is that DGV’s Datasource has a new record with the empty values of the last DGV row and my validation fails. It seems that, although I abandoned insertion, a new record is inserted into the Datasource. If this is true, there should be two empty rows in the grid, the one with the empty values I just entered and the new “new record” row….(by the way, a “new” icon there would be very useful, like the “*” icon in old dgv’s).

So, if the underlying behaviour is as I suspect, there should be two empty rows to indicate that a new (empty value row) was inserted.

The ideal would be that if nothing is inserted in the new row, there is nothing added to the Datasource.

Unless I’m missing something! 🙂

Best,
Alex

  • You must to post comments
0
0

Hi Alex,

This is the general behavior when AllowUserToAddRows is true:

  • When you type in a cell in a new row (row.IsNewRow == true) and leave the cell the value is committed (only if not empty or different from what was there before in case the new row had default values) and the new row is added to the connected data source. Until then it’s not in the data source. After the new row is committed (added to the data source) the grid fires OnUserAddedRow().
  • When a new automatic row is added, the grid fires OnNewRowNeeded, if VirtualMode is on, and then fires OnDefaultValuesNeeded to let the app initialize the automatic new row. You can check in the code to see if it’s the automatic new row by testing row.IsNewRow.
  • If you press Escape while editing in an automatic new row, or don’t change the cell value, the row is not committed, not added to the data source.

The new row icon (+) is there already, also with the editing icon (pencil). But you probably need to update the Classic-2 theme in your app. Hopefully the themes won’t change much after the release. The next two big changes in all the themes will be: ListView, PropertyGrid, and the Collapsible Nested Rows in the DGV.

HTH

Best,

Luca

  • 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 5, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json