Multiple Selection in Listbox when Edit the form

G

Guest

Hi,
I have form where i am using a listbox where we can select multiple values.I
am storing the selected values concatenating with commas(for eg.
"22,21,19,16").Now i have to update this form, so i have to retrieve these
values and to hightlight the previously selected values.

If HcbTypeRecordsOld(i) <> "" Then 'HcbTypeRecordsOld(i)
values from the database is "22,21,19,16"
If Split(HcbTypeRecordsOld(i), ",").Length > 1 Then
'Checking for multiple selection
Dim j As Integer
For j = 0 To Split(HcbTypeRecordsOld(i),
",").Length - 1
Dim
strSelectedValue(Split(HcbTypeRecordsOld(i), ",").Length) As String
strSelectedValue =
Split(HcbTypeRecordsOld(i), ",")
Dim iSelectedIndex As Integer
iSelectedIndex =
Convert.ToInt32(strSelectedValue(j))
cbTypeRecords.SelectedIndex = iSelectedIndex
Next
Else
cbTypeRecords.SelectedIndex =
Convert.ToInt32(HcbTypeRecordsOld(i))
End If
End If
How to set all the values as selected? Now "16" only set as selected.

Thanks
Kumar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top