Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
复选框始终返回False vb.net_Vb.net_Datagridview - Fatal编程技术网

复选框始终返回False vb.net

复选框始终返回False vb.net,vb.net,datagridview,Vb.net,Datagridview,当我选中DatagridView中的复选框时,我想显示消息“True”,但它总是显示“False”我在寻找解决方案这是我的代码 Try 'opening the connection con.Open() If row.Cells(15).FormattedValue = False Then 'store your delete query to a variable(sql)

当我选中DatagridView中的复选框时,我想显示消息“True”,但它总是显示“False”我在寻找解决方案这是我的代码

    Try
        'opening the connection
        con.Open()
            If row.Cells(15).FormattedValue = False Then
                'store your delete query to a variable(sql)
                sql = "DELETE FROM terres WHERE id = '" _
                            & CStr(row.Cells(3).FormattedValue) & "'"
                MsgBox(row.Cells(3).FormattedValue)
                'Set your MySQL COMMANDS
                With cmd
                    .Connection = con
                    .CommandText = sql
                End With
                'Execute the Data
                result = cmd.ExecuteNonQuery
            End If
        Next
        'the condition is, if the result is equals to zero
        'then the message will appear and says "No Deleted Record."
        'and if not the message will appear and says "The Record(s) has been deleted.."
        If result = 0 Then
            MsgBox("No Deleted Record.")
        Else
            MsgBox("The Record(s) has been deleted.")
        End If
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
    'Close the connection
    con.Close()

在构建DataTable/DataGridView时,请对复选框列尝试以下操作:

dtdgv.Columns.Add("Process", GetType(Boolean))
'More columns etc.
'Seriously look at table adapters and 
'make SURE they wont work for your application
'Fill dtdgv
DataGridView1.DataSource = dtdgv
DataGridView1.Refresh()
然后,在确定是否对此进行了检查时:

For Each row As DataGridViewRow In DataGridView1.Rows
    If row.Cells("Process").Value = True Then
        'Stuff
    End If    
Next

这就是你要找的吗?

这看起来不像C。你为什么给它贴上这样的标签?代码中的复选框在哪里?它的价值何在?当你在调试器中看到它时,它的值是什么?你能发布datagridview的标记吗?我如何使用vb 2008@Rickjames实现这一点?为什么不让datatable和dataadapter为你实现这一点?综合考虑,您应该阅读并将“optionstricton”类型作为代码文件的第一行,然后修复错误。