Hi everyone,
With help from "dbasnett" i am able to show Checkedlistbox1 items into listbox2.

Now what i am trying to achieve is that if listbox2 contains checkedlistbox1 items then checkedlistbox1 should retain checked state even after the from is closed and re-opened again.

Since i am saving the checkedlistbox1 values into a Table - is it possible to bind those to retain the checked state even after the from is closed and re-opened again - or it can be done comparing the values from both listboxes - any ideas!!


I tried this but unsuccessful so far.

Any help

Cheers
IrFi


Code:
'-------------- This code from "dbasnett" is working FINE

Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, _
                                          ByVal e As System.Windows.Forms.ItemCheckEventArgs) _
                                      Handles CheckedListBox1.ItemCheck
        If e.NewValue = CheckState.Checked AndAlso _
            Not CheckedListBox2.Items.Contains(CheckedListBox1.Items(e.Index)) Then
            CheckedListBox2.Items.Add(CheckedListBox1.Items(e.Index))

Call AddRecordToTable() ' Made a function to save selection into Table in SQL

        ElseIf e.NewValue = CheckState.Unchecked AndAlso _
             CheckedListBox2.Items.Contains(CheckedListBox1.Items(e.Index)) Then
            CheckedListBox2.Items.Remove(CheckedListBox1.Items(e.Index))
        End If
    End Sub

Code:
' --------Having trouble with this code 

For i As Integer = 0 To Me.Checkedlistbox1.Items.Count - 1
            If ListBox2.Items.Contains(Checkedlistbox1.Items(i)) Then
                Checkedlistbox1.CheckedItems(i) = True
            End If
        Next