all groups > vb.net controls > june 2006 >
You're in the

vb.net controls

group:

How to iterate thru combobox ?


How to iterate thru combobox ? Tony Girgenti
6/23/2006 8:18:01 AM
vb.net controls:
Hello.

Using VS.NET 2003(VB), .NET Framework 1.1.4322, ASP.NET 1.1.4322, WSE2.0 on
a WinXP Pro Sp2 computer.

How do i loop thru a combobox to extract each SelectedItem in the combobox
from selecteditem 1 thru to the end of the combobox ?

I want to ignore selecteditem 0 (Zero). I know it's not really the
selecteditem, as in "selected by the user from the dropdown list", but to
iterate thru all the items in the combobox.

Any help would be gratefully appreciated.

Thanks,
Tony


Re: How to iterate thru combobox ? Dave
6/26/2006 6:59:05 AM
With comboboxes you can only select one item anyway.... could you
please explain this a little bit clearer?


[quoted text, click to view]
Re: How to iterate thru combobox ? Tony Girgenti
6/26/2006 3:22:37 PM
Hello Dave.

Thanks for your reply.

When a combox is populated with say, the following:
Tony
Dave
Frank
Joe
Mary
Judy

Each name is a different item in the combobox. As a user, I can't see all
the names in the combobox until i use the drop down arrow associated with the
combobox, but they are there even when i don't use the dropdown arrow. One
of the items in the combobox(the first one) appears in the combobox text area
before you use the dropdown arrow to view the remainder of the items in the
combobox.

I want to programmatically go thru each item in the collection of items that
appear in the combobox(when i use the dropdown arrow). So, in my program if
i were to grab the first item in the combobox, the program would see "Tony"
I want to be able to do something with "Tony", then go and get the next item
in the combobox. Now, i would see the next item in the combobox, that would
give me "Dave". Now, i can do something with "Dave", and so on.

Programmatically, the dropdown arrow was not clicked, but all of those
entries are in the combobox. Is that true ? It's really a table of entries
and that table is in the combobox.

I hope this help you understand what i am trying to do.

Thanks,
Tony

[quoted text, click to view]
Re: How to iterate thru combobox ? Dave
6/26/2006 11:44:45 PM
Im still not completely sure what you are after, but the items
themselves are stored in the ComboBox.Items. You can Iterate through
this collection to access all of the items in the combobox.

Is this what you want?

[quoted text, click to view]

This is how a combobox works, if you want to see all the items at the
same time, use the listbox not the combobox.

[quoted text, click to view]

foreach str as string in ComboBox.Items
'Will print out the name of each item in the combobox to
the Console
Console.writeline(str)
next

Dave
Re: How to iterate thru combobox ? Tony Girgenti
6/27/2006 8:18:02 AM
Thanks Dave.

That's exactly what i want. I think ? I haven't tried it yet.

Tony

[quoted text, click to view]
AddThis Social Bookmark Button