Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Scan to Item in Combo Based on ValueMember
Message
From
21/10/2003 12:21:29
 
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
00840605
Message ID:
00840711
Views:
21
>How do I determine the index of an item in a combobox based on the valuemember property?<

Are you talking about the selected item of a combobox or do you just want to scan through each item until you find the one you're looking for?

There's quite a few .Selected properties (.SelectedIndex, .SelectedItem, .SelectedIndices, etc.) if that's what you're looking for.

If you just want to scan through each item, then do something like this:
for (int i=0; i < MyCombo.Items.Count; i++)
{
    if (MyCombo.Items[i].ToString() == WhatToLookFor)
    {
        // put code here for finding it
        break;
    }
}
~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform