|
-
May 10th, 2013, 07:19 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Don't hit me - How to get a general DataRow.EndEdit event
Hello!
I'm sorry, but I am stuck again.
I have filled a DataGridView with data. Now I let the user add a new row, and I need to catch an event after the user has finished to edit the row, so that I can update the database.
There is this DataRow.EndEdit event, but I cant find a way to handle this event, as the new row filled by the user is an anonymous row.
Do I have to have a Class member of type DataRow and then when the user starts to enter the data (I can catch it in a grid.SelectionChanged event) I have to set the class member to the current row?
It seems like a strange way to me. But the DataGridView does not seem to offer any event that would fit me.
Kind regards,
Andy
-
May 10th, 2013, 08:53 AM
#2
Addicted Member
Re: Don't hit me - How to get a general DataRow.EndEdit event
 Originally Posted by AndyLD
Hello!
I'm sorry, but I am stuck again.
I have filled a DataGridView with data. Now I let the user add a new row, and I need to catch an event after the user has finished to edit the row, so that I can update the database.
There is this DataRow.EndEdit event, but I cant find a way to handle this event, as the new row filled by the user is an anonymous row.
Do I have to have a Class member of type DataRow and then when the user starts to enter the data (I can catch it in a grid.SelectionChanged event) I have to set the class member to the current row?
It seems like a strange way to me. But the DataGridView does not seem to offer any event that would fit me.
Kind regards,
Andy
vb.net Code:
Private Sub dataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dataGridView1.CellEndEdit
'Code Here
End Sub
That should work, if ya need more info. Right here ---> http://msdn.microsoft.com/en-us/libr...llendedit.aspx
-
May 10th, 2013, 09:05 AM
#3
Re: Don't hit me - How to get a general DataRow.EndEdit event
It doesn't matter if the user can add a new row, the DataGridView does off an event that you need. It's called the CellEndEdit. Take a look at this example:
Code:
Private Sub DataGridView1_CellEndEdit(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
MessageBox.Show(String.Format("Row: {0} {1} Column: {2}", e.RowIndex, Environment.NewLine, e.ColumnIndex))
End Sub
I handle the DataGridViewCellEventArgs to get the current rowindex and the current column index.
Edit - Crzyrio beat me to it!
-
May 10th, 2013, 10:18 AM
#4
Thread Starter
Addicted Member
Re: Don't hit me - How to get a general DataRow.EndEdit event
Many thanks to both of you. I must have been blind, i scrolled the eventlist of the grid and I didnt see this one. Then I searched the net, but you cant find much on such simple and obvious solutions as very few people dont find this by themselves.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|