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


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
 
Ad

Advertisements

C

ClayB

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.
 
Ad

Advertisements

N

nvx

Thank you very much, it seems to be doing what I need... :)

With regards
nvx


ClayB napsal:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top