Listbox and Checkbox list in VB 2008
I am hoping someone out there has encountered this and can help. I've spent way too much time and getting no where. Also, if you can't help but know where I could go for asstance, that would be most appreciated.
I am developing a survey type app that allows the user to check items off in a checkbox list.
The checkbox list are pulled from a db. When the user saves the selected items, it is saved to a different table in the db.
I have a hidden list box on the page. When the page loads, it checks the db to see if that user had been there before and pulls up their previous selections.
My issue is that I can't figure out how to search through the Listbox and compare it to the checkbox list and if they have matching values, set the matched items in the check box list as selected.
Would anyone out there be able to help?
Re: Listbox and Checkbox list in VB 2008
This piece code is your required solution :D :
Put this inside the
The code is quite self-explanatory, but let me briefly explain it :
(1) It scans through all the selected items in the listbox.
(2) For each selected item, it performs a search on the CheckedListBox and retrieves the index of the item.
(3) It then sets the CheckState of that index to CheckState.Checked. :)
|All times are GMT +5.5. The time now is 20:36.|