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.

有帮助吗?

解决方案

(Not sure because of tags, I am assuming you are using WinForms for your application).

Try the following:

combobox.SelectedValue = "Computer";
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top