Results 1 to 4 of 4

Thread: [RESOLVED] Don't hit me - How to get a general DataRow.EndEdit event

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2013
    Posts
    134

    Resolved [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

  2. #2
    Addicted Member
    Join Date
    Jan 2013
    Posts
    177

    Re: Don't hit me - How to get a general DataRow.EndEdit event

    Quote Originally Posted by AndyLD View Post
    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:
    1. Private Sub dataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dataGridView1.CellEndEdit
    2. 'Code Here
    3. End Sub

    That should work, if ya need more info. Right here ---> http://msdn.microsoft.com/en-us/libr...llendedit.aspx

  3. #3
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,376

    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!
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 2013
    Posts
    134

    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
  •  



Click Here to Expand Forum to Full Width