Hi,
Did my last answer help you?
In addition, do you mean when you populate the checkedlistbox and then
check some items and then you repopulate the checkedlistbox, you wants to
persists the checked state.
I think you may still need to persist the checked state yoursefl.
Here is a sample, you may have a look.
Dim checkedList As Collection
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
'Clear the Last Saved Checkedstate List
checkedList = New Collection
'Save the Current Checkedstate List
For Each o As Object In Me.CheckedListB ox1.CheckedItem s
checkedList.Add (o.ToString()) 'the string must be unique, or
you need to select another value to unique identity the item
Next
'RePopulate the checkListBox
Me.CheckedListB ox1.Items.Clear ()
For i As Integer = 1 To 3
Me.CheckedListB ox1.Items.Add(D ataSet11.Table1 .Rows(i).Item(0 ).ToString())
Next
'Restore the Last Saved Checkedstate List
For Each o As String In checkedList
Dim i As Integer =
Me.CheckedListB ox1.FindStringE xact(o.ToString ())
If Not i = -1 Then
CheckedListBox1 .SetItemChecked (i, True)
End If
Next
End Sub
Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Me.SqlDataAdapt er1.Fill(Me.Dat aSet11)
For Each o As DataRow In DataSet11.Table 1.Rows
Me.CheckedListB ox1.Items.Add(o .Item(0).ToStri ng())
Next
End Sub
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.