I am trying to bind two values to a ComboBox display value, but I do not know how to do.
This way does not work:
cboRegion.DisplayMemberPath = "idregion" + "description";
Does anyone know how to do that in C#?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unfortunately, this is not possible with
DisplayMemberPath. You have the following alternatives:Specify a DataTemplate
(If you are wondering about the empty braces in the StringFormat attribute, see: What do the {} brackets mean in the StringFormat section of a Binding syntax?)
Add a property or field to your data source. How to do that depends on your data source:
If your combo box is bound to a DataTable, add a DataColumn and fill its values in a loop. Alternatively, change your SQL and add the concatenated value to your
SELECTclause.If your combo box is bound to a POCO or entity framework object, add a property that returns the concatenation.