Question Having Displaymember and Valumember for TextBox

dineshkumaar

Member
Joined
Jun 5, 2009
Messages
21
Programming Experience
10+
Can we have a Displaymember and Valuemember property (like combobox) for a TextBox so that if i user types a string value in the textbox, its Text Property will have the string and Value property will have its ID (Primary Key value).

Please help!

Regards
 
The concept of a DisplayMember and ValueMember don't make sense for a TextBox because it doesn't have a DataSource property. You cannot bind a list to a TextBox the way you do a ComboBox. TextBoxes only support simple data-binding, not complex data-binding. If you change the Text of a TextBox then you change the value of the currently bound item, rather than selecting a different item.

What exactly are you trying to achieve? Please provide a full and clear description and we can provide the most appropriate solution.
 
I believe displaymember and valuemember are properties of the combobox control and not the textbox, but maybe you can pass the primary key value to the textbox and convert it to the corresponding text property?
 

Latest posts

Back
Top