Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1170
Dumb question, but what is the difference between the text and value property
posted

Why are there two different properties for what would intuitively be the same thing (value/text)... i.e., vs. a single get/set text property?

Parents
  • 469350
    Offline posted

    Text is a string. It represents the actual text the user sees on the screen. 

    Value is an object and can be any value.

    The reason they are different is because you can use the Combo as a sort've lookup table. So, for example, you might have a database with a list of customers. Each customer has a unique ID Number and a name. If you displayed customers in a Combo, you would want the user to see the names, but you want to save the ID to your DataBase. So you bind the Combo to the list of customers and set the ValueMember to the ID field and the DisplayMember to the name field. 

    The combo will now display the DisplayMember (name) field to the user. The Text property of the Combo will return what the user sees - the name. But the Value will return the ID field. 


Reply Children