如何在更新datagridview中的复选框之前显示一个msgbox?
假设我在 Datagridview 中有一行带有复选框,它的值为 True(Checked),我将单击它。我怎样才能先展示这样的东西?
“您确定要取消选中此项吗?是或否”
是 = 取消选中
否 = 还是一样(选中)
这是我想要的输出的代码,但它不起作用
Private Sub DataGridView3SelectAll_CurrentCellDirtyStateChanged(
ByVal sender As Object,
ByVal e As EventArgs) Handles DataGridView3.CurrentCellDirtyStateChanged
RemoveHandler DataGridView3.CurrentCellDirtyStateChanged,
AddressOf DataGridView3SelectAll_CurrentCellDirtyStateChanged
If TypeOf DataGridView3.CurrentCell Is DataGridViewCheckBoxCell Then
DataGridView3.EndEdit()
Dim Checked As Boolean = CType(DataGridView3.CurrentCell.Value, Boolean)
Dim xx As String
xx = MsgBox("Are you sure you want to save changes?", vbYesNo)
If xx = vbYesNo Then
If Checked = True Then
Dim s As String = (DataGridView3.Columns(DataGridView3.CurrentCell.ColumnIndex).DataPropertyName)
Dim x As Integer
x = DataGridView3.CurrentCell.RowIndex
Dim con1 As MySqlConnection = New MySqlConnection("datasource=192.168.2.87;database=inventory;userid=root;password=admin1950")
Dim cmdinsert As MySqlCommand = New MySqlCommand("update stock_issuance set `" & s & "` = 1 where `" & s & "` = `" & s & "` and Month = '" & DataGridView3.Rows(x).Cells(1).Value & "'", con1)
con1.Open()
cmdinsert.ExecuteNonQuery()
con1.Close()
ElseIf Checked = False Then
Dim s As String = (DataGridView3.Columns(DataGridView3.CurrentCell.ColumnIndex).DataPropertyName)
Dim x As Integer
x = DataGridView3.CurrentCell.RowIndex
Dim con1 As MySqlConnection = New MySqlConnection("datasource=192.168.2.87;database=inventory;userid=root;password=admin1950")
Dim cmdinsert As MySqlCommand = New MySqlCommand("update stock_issuance set `" & s & "` = 0 where `" & s & "` = `" & s & "` and Month = '" & DataGridView3.Rows(x).Cells(1).Value & "'", con1)
con1.Open()
cmdinsert.ExecuteNonQuery()
con1.Close()
End If
Else
End If
End If
AddHandler DataGridView3.CurrentCellDirtyStateChanged,
AddressOf DataGridView3SelectAll_CurrentCellDirtyStateChanged
End Sub