How to get combo items
-
Hi all, i have problem with combobox collection items. :^)i need to check all entrys in combo box with foreach, i know the way but i dont know the exact class for combo box items(like ListItem).Thank u. Best Regards, ranandbe. -- modified at 1:20 Wednesday 7th June, 2006
-
Hi all, i have problem with combobox collection items. :^)i need to check all entrys in combo box with foreach, i know the way but i dont know the exact class for combo box items(like ListItem).Thank u. Best Regards, ranandbe. -- modified at 1:20 Wednesday 7th June, 2006
-
try out following for(int i=0;i < comboBox1.Items.Count;i++) { MessageBox.Show(comboBox1.GetItemText(comboBox1.Items[i])); } rahul -- modified at 1:39 Wednesday 7th June, 2006
-
thank u for replying, now i work with the same what you send but i want to know using foreach statement. Thanks & Regards., ranandbe
-
Hi all, i have problem with combobox collection items. :^)i need to check all entrys in combo box with foreach, i know the way but i dont know the exact class for combo box items(like ListItem).Thank u. Best Regards, ranandbe. -- modified at 1:20 Wednesday 7th June, 2006
In a combo box the items are just strings so you can do this: foreach (string itm in comboBox1.Items) { MessageBox.Show(itm); } HTH
-
In a combo box the items are just strings so you can do this: foreach (string itm in comboBox1.Items) { MessageBox.Show(itm); } HTH
MCSD-Gandalf wrote:
In a combo box the items are just strings...
Not always true. The
Items
property is anObjectCollection
because you can stuff whatever you want in the collection, and render the Items yourself in a custom drawing routine. It's usually strings, but not always. Share and enjoy. Sean -
MCSD-Gandalf wrote:
In a combo box the items are just strings...
Not always true. The
Items
property is anObjectCollection
because you can stuff whatever you want in the collection, and render the Items yourself in a custom drawing routine. It's usually strings, but not always. Share and enjoy. SeanVery true. Of course HOPEFULLY if you have stuffed something else in there you know what it is and can write the appropriate foreach loop. And if not I guess you can always treat everything in there as an object and write the foreach loop that way. Guess I need to be a bit clearer around here with all you guru's watching:laugh: ! Thanks! Gandalf
-
Very true. Of course HOPEFULLY if you have stuffed something else in there you know what it is and can write the appropriate foreach loop. And if not I guess you can always treat everything in there as an object and write the foreach loop that way. Guess I need to be a bit clearer around here with all you guru's watching:laugh: ! Thanks! Gandalf
MCSD-Gandalf wrote:
Guess I need to be a bit clearer around here with all you guru's watching
The comment wasn't so much for you; it was intended for people who are less well informed who may read the thread later. I don't usually presume to correct MCSDs. Share and enjoy. Sean