Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tick items in checkedlistbox from items in listbox 1

Status
Not open for further replies.

basbrian

Programmer
Feb 18, 2002
49
AU
I have a checkedlistbox that contains a list of all codes and a listbox that contains the codes that have been assigned to an employee. when the listbox is loaded I want to put a tick in the checkbox of the corrosponding code in the checkedlistbox.How can I do this?

Thanks in advance

Brian
 
Something like this should work:

Code:
        For i As Integer = 0 To MyCheckedListBox.Items.Count - 1
            Dim found As Boolean = False
            For j As Integer = 0 To MyListBox.Items.Count - 1
                If MyListBox.Items(j).ToString = MyCheckedListBox.Items(i).ToString Then
                    found = True
                    Exit For
                End If
            Next
            MyCheckedListBox.SetItemChecked(i, found)
        Next
 
Thanks Riverguy, whatever they are paying you is not enough. :)

However, I did have to change
MyListBox.Items(j).ToString = MyCheckedListBox.Items(i) to
MyListBox.Items(j).item(0).ToString = MyCheckedListBox.Items(i).item(0).tostring
for it to work.

Thanks alot for the timely response.

Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top