Link to home
Start Free TrialLog in
Avatar of astafate
astafate

asked on

How to retrieve checked values from databound checkedlistbox windows vb.net

I have a Checkedistbox bound to a dataset. I need to get out the checked selecteditemvalue from each one that is checked to get send to my insert query for another table. this is multi select. I need code for selectedindexchages of a button onclick either one will do. thank you.

here is my code on popluating the checklistbox1

 Dim myconn As OleDbConnection = New OleDbConnection(Cnn)
        Dim mydap As New OleDbDataAdapter
        Dim dbcom As OleDbCommand
        Dim mydsLmat As New DataSet

        Dim strSQL As String
        strSQL = "SELECT PickID, PickName FROM Picklist WHERE Picktype = 'O' OR Picktype = 'C'"

        Try
            CheckedListBox1.DataSource = Nothing
            dbcom = New OleDbCommand(strSQL, myconn)
            mydap = New OleDbDataAdapter(dbcom)
            myconn.Open()
            CheckedListBox1.Items.Clear()
            mydsLmat = New DataSet

            mydap.Fill(mydsLmat, "Picklist")
            CheckedListBox1.DisplayMember = ("PickName").ToString
            CheckedListBox1.ValueMember = ("PickID").ToString
            CheckedListBox1.DataSource = mydsLmat.Tables(0)
            myconn.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
            mydsLmat.Dispose()

        End Try
ASKER CERTIFIED SOLUTION
Avatar of DotNetLover_Baan
DotNetLover_Baan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial