Your technology certification is waiting. Enroll in Cloud Class ®
cmbBox.SelectedIndex = 0; //<-- Set the number of the index location of the option you want as your default here
Open in new window
cmbBox.SelectedIndex = cmbBox.FindString(@"YourValueHere");
int index = cmbBox.FindString(@"YourValueHere");
This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.
public void SearchComboBox(ComboBox cbTest,string searchValue,string searchFlag)
case "I" :
cbTest.SelectedIndex = Int32.Parse(searchValue);
case "V" :
cbTest.SelectedValue = searchValue;
case "T" :
cbTest.SelectedItem.ToString() = searchValue;
cbTest.SetSelected(0,true);//Select First Index..
SearchComboBox(comboBox1,"2","I"); //TO SELECT 2nd Index Position.
SearchComboBox(comboBox1,"myValue","V"); //TO SELECT Value "myValue" from list..
SearchComboBox(comboBox1,"xyz","lkj"); //TO SELECT 0 index by default..
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.