Reputation: 441
i would like to ask a question. i have a five button and one combo box in my windows form. combo box have 5 items to select in their collection.
eg.
1.John
2.Steve
3.Seven
4.Jhone
5.Eistein
like that.
i want to manually select the items in combo box with button's event. when i click Seven button,that combo box will automatically select John to Seven. Or select Eistein that combo box's select item will automatically select Seven to Eistein. How can i do that?
Please let me know if you can do that. Thanks your for your time. :)
Upvotes: 0
Views: 725
Reputation: 151588
Use FindStringExact:
private void einsteinButton_Click(object sender, EventArgs e)
{
int item = ComboBox.FindStringExact("Einstein");
if (item >= 0)
ComboBox.SelectedItem = item;
}
Upvotes: 2