How to force DataGridView to add the new (just filled in) row into itself manually? (C#)

  • Thread starter Thread starter nvx
  • Start date Start date
N

nvx

Hi,
I have a DataGridView and a toolbar with buttons. I need to force
DataGridView to validate and add the row user has just filled in
(which is still not the part of the actual DGV.Rows collection, I
guess) to itself after clicking on the toolbar button.

The situation is this:
1. I have a DataGridView, one row (the last) is empty -- for new data
2. I start typing into this empty row, new empty row appears
immediately while the edited row is still not part of the DGV.Rows
collection.
3. I click on the toolbar button and need the edited row to be
validated and, if validation succeeds, added into the DGV.Rows
collection

The problem is the edited row becomes part of the collection after I
click into the new empty row (and maybe after some other events
occur), which is not what happens. Instead, I click on the toolbar
button and it seems like the DGV never even loses focus...

Sorry for this indistinct description...

Any ideas?

TIA

With regards
nvx
 
Try calling

this.Validate();

at the beginning of your toolbar button handler code to see if that
makes things work the way you want them to.

=====================
Clay Burch
Syncfusion, Inc.
 
Back
Top