1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
Private Sub SupprimerToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SupprimerToolStripMenuItem.Click
'menu DataGridView suppimer un element d'une ligne
If cn.State = ConnectionState.Open And DataGridView1.Rows.Count > 0 Then
Dim indexDel As Integer
indexDel = DataGridView1.CurrentCell.RowIndex
Dim cmd As New MySqlCommand("DELETE FROM " & tableTxt.Text & " WHERE ID=@id", cn)
cmd.Parameters.AddWithValue("@id", ID)
cmd.ExecuteNonQuery()
DataGridView1.Rows.RemoveAt(indexDel)
MessageBox.Show("Supprimé")
End If
End Sub |
Partager