Use selected text instead of selectedIndex
Question
I have a dataset
connected to a bindinglist
that is connected to a combobox
in win32.
I would like to make "Computer" to be selected as a displaymember
in the combobox
when I have a private string with value "Computer".
The main issue is that it doesn't work to use SelectedText
in the combobox
to make "Computer" to be selected but it works properly when I use selectedIndex
. But, in order to use selectedIndex
, you have to know the row number from table in order to make the text to be selected.
Solution
(Not sure because of tags, I am assuming you are using WinForms for your application).
Try the following:
combobox.SelectedValue = "Computer";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow