Dave,
I am currently using a for loop, but I wanted to change it to a foreach (reason unknown <s>).
I thought the items collection stored the type of whatever I put in there, but that didn't work. Looking closer at it after reading your reply it seems like i have several int32 items in my combo and one string item and that is why it didn't work for me.
Thanks for the reply.
Einar
>The List collection stores objects so the type should be whatever type you are storing in the collection, string, int, custom type, etc.
>
>Of course you can always use a for loop if you can't get foreach to work. In my case I am storing a custom type called ListItem.
>
>
>for (int i = 0; i < cbo.Items.Count ; i++)
>{
> ListItem item = (ListItem)cbo.Items[i];
> if (item.IntValue == lookingForValue)
> {
> cbo.SelectedItem = item;
> break;
> }
>}
>
>
>
>
>
>
>>I am trying to do a foreach on all the items in a combobox, but I am having problems finding the correct type
>>
>>
>>foreach (<type> oItem in this.myComboBox.Items)
>>{
>> MessageBox.Show(oItem.ToString());
>>}
>>
>>
>>Anyone know what
type I need to use or is there a better way to go through all items in a combobox?
>>
>>Thanks,
>>Einar
Semper ubi sub ubi.