这是复选框列表检查vb.net窗体

时间:2014-10-02 06:15:33

标签: vb.net

我想在数据库中添加多条记录,但是我收到以下错误:

Conversion from type 'DataRowView' to type 'Integer' is not valid.

我的代码如下:

Private Sub CheckedListBox1_ItemCheck(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox1.ItemCheck

    Dim SelectedMainCat As Integer
    Dim DMV As DataRowView = TryCast(CheckedListBox1.SelectedItem, DataRowView)

    If DMV IsNot Nothing Then

        'SelectedMainCat = DMV.CheckedItems(n)

        For n As Integer = 0 To CheckedListBox1.CheckedItems.Count - 1
            Dim userWants As Integer = CheckedListBox1.CheckedItems(n)
        Next n


    End If

End Sub

1 个答案:

答案 0 :(得分:0)

谢谢现在我的代码再次谢谢你

Private Sub CheckedListBox1_ItemCheck(ByVal sender As System.Object,ByVal e As System.Windows.Forms.ItemCheckEventArgs)Handles CheckedListBox1.ItemCheck

    Dim SelectedMainCat As DataRowView
    Dim DMV As DataRowView = TryCast(CheckedListBox1.SelectedItem, DataRowView)

    If DMV IsNot Nothing Then



        For n As Integer = 0 To CheckedListBox1.CheckedItems.Count - 1
            SelectedMainCat = CheckedListBox1.CheckedItems(n)
            Dim userWants As DataRowView = DirectCast(CheckedListBox1.CheckedItems(n), DataRowView)

            **'insert query**


        Next n


    End If
End Sub