0

Hi All,

Can someone tell me how to set the selected text of a combobox on windows form with C#. If the combobox is unbound ie. has a static item list then combobox1.selected.text = "mtetxt"; works fine. However when the box is databound to a list from a database this does not work. I could use selectedindex but my database list may change, therefore changing the required index. I have found some other forums suggesting this is a glitch with the combobox object but offer no workaround.

Any help with this would be greatly appreciated.

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by ChrisHunter
0

Try to first search your items for the required text to find out its index, then select that index from the box

0

Hi Emilo35,

I have tried searching the items and then selecting the one i want but it still wont work. Have you got some sample code?

0

Is your problem that in the time between loading your form (which will populate your comboBox automatically because it's databound) and selecting a comboBox item the data in the database may have changed and you would like your comboBox to update if the data in the database is changed ?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.