How to check items if they are in a listbox
Okay, I'm not sure how to explain this correctly but I'll give it a shot.
On Form_Load I am enumerating values in a reg key and then displaying all the reg values that are in the key into a listbox. After that I want to check items (in a checkedlistbox) that are the same as those in the listbox. Is this even possible? If so please help!
Thanks in advance
# 1 Re: How to check items if they are in a listbox
Sure, it's possible. What problem(s) are you having?
# 3 Re: How to check items if they are in a listbox
What don't you know how to do:
- Enumerate registry keys
- Populate listbox
- Find matching items in CheckedListBox
- Check items in CheckedListBox
?
# 4 Re: How to check items if they are in a listbox
I know how to:
-Enumerate Values
-Populate Listbox
-Check listbox items
I don't know how to:
-(I want to) Check checkedlistbox items if the items are in the listbox (which has the enumerated values) :)
I hope this clears things up a bit...
# 5 Re: How to check items if they are in a listbox
Try this:
For Each item As Object In lstBox.Items
Dim index As Integer = lstChecked.FindStringExact(item.ToString)
If index >= 0 Then
lstChecked.SetItemChecked(index, True)
End If
Next