rockhammer99
asked on
How do you set default selected in a combo box in c#.net
How do you set default selected in a combo box in c#.net
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
This will show the possible ways additionally.
http://www.dotnetspider.com/forum/161988-Combo-box-default-Selection-C.aspx
This will show the possible ways additionally.
http://www.dotnetspider.com/forum/161988-Combo-box-default-Selection-C.aspx
Try this method :
public void SearchComboBox(ComboBox cbTest,string searchValue,string searchFlag)
{
switch(searchFlag)
{
case "I" :
cbTest.SelectedIndex = Int32.Parse(searchValue);
break;
case "V" :
cbTest.SelectedValue = searchValue;
break;
case "T" :
cbTest.SelectedItem.ToString() = searchValue;
break;
default :
cbTest.SetSelected(0,true);//Select First Index..
break;
}
}
How to call above method ?? Answer is this way :
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..
I've requested that this question be deleted for the following reason:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Hi,
I have provided the possible solution in comment http:#34922275 Pls review the answers for the question asked before taking decision. And accordingly close the issues.
I have provided the possible solution in comment http:#34922275 Pls review the answers for the question asked before taking decision. And accordingly close the issues.
I get these all the time even though I give them many different solutions. Seems to be more often too. Ignoring your own type of deal here. It's what we have come to know it as a "Fire & Forget" question.
Open in new window
This will give you the index of the Value you want. You can test it by setting a seperate integer and calling it like this.
Open in new window