Capture the NewRow event for a DataGrid

G

Guest

let me set the stage for my question..

A C# winform with one datagrid on it.
A DataTable dt that has some data in it bound to the datagrid using
setbindings().
The Table has these columns in it.
First
Middle
Last
Address
Customer_id

Now, I create a data table style for the datagrid cause I just wanted to
show the First, Middle, and Last name. Not the address.

My question is this... How can I trap when the DataGrid tries to commit the
data I entered in the datagrid to the new data row it created? The reason is
I do not allow the address to be null so when the DataGrid tries to commit
the data to the new datarow it thorws an error about the address field being
blank. What I want to do is trap the commit to validate the data.

Ok, I have tried trapping the RowChanged, and RowChanging events from the
datable but these doesn't get called until sometime after the datagrid has
committed the data to the new datarow.
 
K

Ken Tucker [MVP]

Hi,

http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q823q

Ken
----------------
"(e-mail address removed)"
let me set the stage for my question..

A C# winform with one datagrid on it.
A DataTable dt that has some data in it bound to the datagrid using
setbindings().
The Table has these columns in it.
First
Middle
Last
Address
Customer_id

Now, I create a data table style for the datagrid cause I just wanted to
show the First, Middle, and Last name. Not the address.

My question is this... How can I trap when the DataGrid tries to commit the
data I entered in the datagrid to the new data row it created? The reason is
I do not allow the address to be null so when the DataGrid tries to commit
the data to the new datarow it thorws an error about the address field being
blank. What I want to do is trap the commit to validate the data.

Ok, I have tried trapping the RowChanged, and RowChanging events from the
datable but these doesn't get called until sometime after the datagrid has
committed the data to the new datarow.
 
G

Guest

Thank you Tucker for taking the time but the link you sent me to does not
address the issue I have.

The PositionChanged event is called once during the loading, when you change
row, and once when you dispose of the control. This assumes you have a loaded
datagrid are you are just navigating to another row.

What I am looking for is after you click on the very last row of the
datagrid and enter data into it and then click on the next row that is blank
the data you just entered in, gets committed to the new row it created behind
the scene. I'm looking for a way to trap the commit to validate the data
before it getts written to the new datarow. PositionChanged doesn't get
called until after the data has been "Moved" to the new datarow.

Any more ideas?
 

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