Setting the text in a Combobox

cashdesk

Member
Joined
Jul 5, 2011
Messages
5
Programming Experience
3-5
Hi guys,

I've been working on C# web applications for a few years now, but my boss threw me a curve ball in the shape of a VB.NET Windows application project.

All going quite well so far, but I have retrieved information from the database, populated an object and now I need to set the value in a Combobox. Sounds simple enough, but having tried:

cmbShiftStartTime.SelectedText = s.ShiftStartTime

it no longer seems so easy.

Can someone please tell me how I set the value for a Combobox?

Thanks,

Cash
 
The SelectedText of a ComboBox works exactly the same way as a TextBox. If you select part of the displayed text, that's the SelectedText. If you want to select one of the items in the list then you set one of SelectedItem, SelectedIndex and SelectedValue. The one to set depends on the circumstances.
 
Back
Top