Deleted row of a Datagridview

Hello. A question please. When the user deletes a row of a datagridview, I recognize the event with RowsRemoved.

But how can i recover a value of that deleted row in the rowsremoved event

Thanks...



Answer this question

Deleted row of a Datagridview

  • Bernaridho

    Hi,

    Have you thought about adding the row back into your DataGrid view first

    Regards,

    S_DS



  • MajorDad

    Try the UserDeletingRow event. I think this is fired before the row is actually deleted.

    Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    DataGridView1.Columns.Add("name", "Name")

    DataGridView1.Columns.Add("value", "Value")

    DataGridView1.Rows.Add("greeting", "hello")

    End Sub

    Private Sub DataGridView1_UserDeletingRow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewRowCancelEventArgs) Handles DataGridView1.UserDeletingRow

    MsgBox(e.Row.Cells(0).Value)

    MsgBox(e.Row.Cells(1).Value)

    End Sub

    End Class

    Hope this helps.
    Shyam



  • VladR

    Do you mean like an 'undo' Or is this a databound grid

    To get any items back from a deleted row (the 'row' is soimply an item in the rows collection), you would have to save it somewhere/somehow.

    Perhaps clarify what you are trying to achieve.



  • Augustin Calin

    Non. It's not necessary.
  • UltimateSniper

    NetPochi,

    How is problem going Actually if you manipulate the data using DataSet control, the tables in memory has been modified but the real data stored in database may not be changed. Sometimes, you can also add the transaction in your program and add the callback event for your transaction. I'm not clear about the difference between UserDeletingRow and RowsRemoved event. So I suggest you to use the transaction and the callback if you need to recover your deleted row.



  • Deleted row of a Datagridview