Private Sub DataGridView1_CellContentClick(sender As System.Object, e As DataGridViewCellEventArgs) _
Handles DataGridView1.CellContentClick
Dim senderGrid = DirectCast(sender, DataGridView)
If TypeOf senderGrid.Columns(e.ColumnIndex) Is DataGridViewButtonColumn AndAlso
e.RowIndex >= 0 Then
'TODO - Button Clicked - Execute Code Here
End If
End Sub
Dim sql As String
If (e.ColumnIndex = 3) Then
sql = "Delete * form ... where ... = "
ElseIf (e.ColumnIndex = 4) Then
sql = "Update * form ... where ... = "
End If
'เอา sql ไปใช้งาน