我有一个程序,它看起来像这样
请关注带有选中和红色的值。
假设我将单击一个单元格(复选框列)
如果我单击一个单元格,Msgbox 将首先显示sayonAre you you want to update changes?
如果我单击Yes
该程序将检查其当前值并更新它是这样的。
If value = yes then
value = No
ElseIf value = no then
value = Yes
end if
如果我NO
在 msgbox 中选择当前单元格的值将保持不变。
这是我的代码
If (e.ColumnIndex = 1 AndAlso e.RowIndex >= 0) Then
Dim value = DirectCast(DataGridView1(e.ColumnIndex, e.RowIndex).FormattedValue, Nullable(Of Boolean))
Dim result = MessageBox.Show("Are you sure to uncheck item?", "", MessageBoxButtons.YesNoCancel)
If (value.HasValue AndAlso value = True) Then
If (result = System.Windows.Forms.DialogResult.Yes) Then
If DataGridView1(e.ColumnIndex, e.RowIndex).Value = True Then
DataGridView1(e.ColumnIndex, e.RowIndex).Value = False
Else
DataGridView1(e.ColumnIndex, e.RowIndex).Value = True
End If
ElseIf (result = System.Windows.Forms.DialogResult.No) Then
End If
Else
End If
End If
我的问题是。
当我在消息框中单击“是”时,如何检查单元格的值并反之亦然?当我在消息框中单击“否”时,保持该值或返回其原始值。
我尝试了上面的代码,但它看起来不起作用
TYSM