Unbound Datagridview row delete and cancel using datagridview button
-
sabato 18 agosto 2012 08:44
Hello to everyone,
I have an unbound datagridview in vb2005. I have added rows using text and combo boxes in that datagridview. It is easy to add in datagridview. In the datagridview I have a button column to remove the unwanted row before update. I have used a dialog box when deleting the datagridview row. Which works fine for delete the row only when select the dialog ok and I don't know how to code the cancel the delete option......
So far the code is as:
Private Sub dgvProdDetails_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvProdDetails.CellClick
For Each m_row As System.Windows.Forms.DataGridViewRow In Me.dgvProdDetails.Rows
If m_row.Cells("DgDel").Selected Then
Dim result As DialogResult = MessageBox.Show("Are you sure want to remove the row?", "Remove?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
If Windows.Forms.DialogResult.OK Then Me.dgvProdDetails.Rows.Remove(m_row)
If Windows.Forms.DialogResult.Cancel Then ..............................
End If
Next
End SubI dont know exactly what method can use to cancel ..............the delete action.
Please help me. Thanks in advance....
Tutte le risposte
-
sabato 18 agosto 2012 09:46
Hi, I have found the code.
I have changed slightly and get it work.
Dim result As DialogResult = MessageBox.Show("Are you sure, want to Delete?", "Delete Row", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = Windows.Forms.DialogResult.Yes Then
Me.dgvProdDetails.Rows.Remove(dgvProdDetails.CurrentRow)
End IfThanks..........
- Contrassegnato come risposta Little Jones sabato 18 agosto 2012 09:46
-
lunedì 20 agosto 2012 03:21Moderatore
Glad to see you have found solution and thanks for sharing.
Best regards,
Shanks Zen
MSDN Community Support | Feedback to us
- Modificato Shanks ZenMicrosoft Contingent Staff, Moderator lunedì 20 agosto 2012 03:21

