Deleted row of a Datagridview

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

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

Thanks...

[278 byte] By [NetPochi] at [2007-12-28]
# 1

Hi,

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

Regards,

S_DS

Spidermans_DarkSide at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 2
Non. It's not necessary.
NetPochi at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 3

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.

SJWhiteley at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 4

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

ShyamN at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 5

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.

BrunoYu-MSFT at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...