mercredi 6 mai 2015

How to set selectedValue to Controls.Combobox in c#?

I have a combobox and I see that I am not able to set SelectedValue like this:

cmbA.SelectedValue = "asd"

So I tried to do this

cmbA.SelectedIndex = cmbA.FindString("asd");

Based on How to set selected value from Combobox?

I realised that my combobox is a System.Windows.Controls.ComboBox and not a System.Windows.Forms.ComboBox.

That means that FindString() is not available.

Based on User Control vs. Windows Form I get that forms are the container for controls, but I dont get why the Controls.ComboBox does not implement FindString().

Do I have to write my own code to do what FindString() does for Forms.ComboBox?

Aucun commentaire:

Enregistrer un commentaire