以编程方式检查datagridview中的未选中复选框

时间:2016-10-13 01:36:07

标签: vb.net

我在这里有一个代码,但它不起作用..我正在尝试做的是当消息框出现并询问我是否要继续并选择否则所选复选框将把值更改为false。 / p>

If e.ColumnIndex = 0 Then
        If e.RowIndex >= 0 And e.RowIndex <= Me.dgDispatchPosting.RowCount - 1 Then
            If Me.dgDispatchPosting.Item("Approve_Status", e.RowIndex).Value <> "No Action" Then
                If Me.dgDispatchPosting.Item("chkSelect", e.RowIndex).Value = False Then
                    If MsgBox("This Dispatch Code has been " & vbCrLf & "Do you want to proceed? " & Me.dgDispatchPosting.Item("Approve_status", e.RowIndex).Value & "!", vbQuestion + vbYesNo, "Courier Dispatch Summary ") = MsgBoxResult.No Then
                        Me.dgDispatchPosting.Item("chkSelect", e.RowIndex).Value = False 'Must change the value here (Uncheck)
                    End If
                End If
            End If
        End If
    End If

1 个答案:

答案 0 :(得分:0)

我已经得到了关于如何取消选中datagridview中的复选框的答案。在更改复选框值后,只需在另一列/行中选择/焦点。

If Me.dgDispatchPosting.Item("chkSelect", e.RowIndex).Value = True Then
                    If MsgBox("This Dispatch Code has been " & Me.dgDispatchPosting.Item("Approve_status", e.RowIndex).Value & "!" & vbCrLf & "Do you want to proceed? ", vbQuestion + vbYesNo, "Courier Dispatch Summary ") = MsgBoxResult.No Then
                        Me.dgDispatchPosting.Item("chkSelect", e.RowIndex).Value = False 'Must change the value here (Uncheck)
                        Me.dgDispatchPosting.Item("Approve_status", e.RowIndex).Selected = True 'After Changing the value you must select/ focus in the other column or row to take effect the changes you made in code.
                    End If
                End If