Show valuemember of bound combobox after selection

eric dugas

Member
Joined
Apr 30, 2006
Messages
7
Programming Experience
1-3
Hello everyone. I have an issue and I am hoping someone can help. I would like to show the valuemember of the selected item from a bound combobox. For example, if the datatable is States, and an item is LA=valuemember and Louisiana=displaymember, then I would like to display LA after the display member has been selected from the drop down. Thank you very much for your time.
 
You'd have to set the DropDownStyle to DropDown so that the top portion of control was able to accept input other than items from the list. Then you'd handle the SelectedIndexChanged event and set the Text to the SelectedValue. The drawback is that then the user would be able to enter anything they wanted in the upper portion. You could add code to validate any manual entries or you could use a hack. You could leave the DropDownStyle as DropDownList and place a ReadOnly TextBox control over the upper portion of the ComboBox, but leaving the drop down button exposed, and then set the Text of the TextBox in the SelectedIndexChanged event handler.
 
show valuemember in bound combobox

Thanks for your reply jmcilhinney, I will take both of these suggestions into consideration.
 
Back
Top