Home All Groups Group Topic Archive Search About

Checked List Box Help

Author
12 Jul 2006 1:26 PM
Rob
I am doing something wrong...

I am populating a Checked List box from a stored proc...

CheckedListBox1.DataSource=dsStates.Tables("States")
CheckedListBox1.DisplayMember = "State"
CheckedListBox1.DisplayMember = "State"
"State" is the column in the table...

And the above works fine... All the states are shown in the CheckedListBox


I then want to loop thru to find the ones that were checked (process is
invoked from a button)...

Dim i as integer

For i=0 to CheckedListBox1.Items.Count -1
  If CheckedListBox1.GetItemChecked(i)= true then
     Msgbox ("Checked: " & CheckedListBox1.GetItemText(i))
  End if
Next

The above code will give me the integer associated with the row number, but
how do I return the value of the rows contents (i.e., FL) ?

Author
12 Jul 2006 3:42 PM
c_shah
For Each Item As Object In CheckedListBox1.CheckedItems
            MsgBox(CheckedListBox1.GetItemText(Item))
Next
Author
12 Jul 2006 3:43 PM
c_shah
For Each Item As Object In CheckedListBox1.CheckedItems
            MsgBox(CheckedListBox1.GetItemText(Item))
Next
Author
12 Jul 2006 3:50 PM
Rob
Thank you very much !


Show quoteHide quote
"c_shah" <shah.chi***@netzero.net> wrote in message
news:1152719000.731753.242170@35g2000cwc.googlegroups.com...
> For Each Item As Object In CheckedListBox1.CheckedItems
>            MsgBox(CheckedListBox1.GetItemText(Item))
> Next
>