How to make the user choose one value and substitute another. For example, the user selects the product name, and in the value ( SelectedValue
) is his ID passed?
1 answer
As correctly written in the comment, use DisplayMemberPath to display the name, SelectedValuePath
specify "ID" and then calling SelectedValue will get the value of the corresponding property. In general, it is as if you could learn From the manual , or googling
- SO is designed primarily for beginners. you should not be surprised that 80% of the questions here can be solved simply by running - PashaPash ♦
- I understand @PashaPash, but still in the introductory tour of the site there is a point that in the first paragraph it is written in the official help Before you ask a question , make sure you do a thorough search for the answer. And, in the end, I don’t see that it’s bad to once again remind the person about the benefits of search engines, especially considering the fact that the answer is on the first Google link issued - Gromy
- the first link says show your work, not "google first!". on the second - a thorough search for an answer - this is a link to the site search page - and he urges not to post duplicates. but does not send to google. The goal of SO is for the very first link from Google to have a full-fledged answer on SO itself, and for ruSO - the answer in Russian. in the first place in Google - a very well-written answer to enSO - and it is there only because Chris Anderson did not send the topicaster to the manula , but sat down and wrote a detailed answer. - PashaPash ♦
- @PashaPash In a sense, you are right. Just for me, show your work is a question of the form: Here I have the following problem
X
I read in the official documentation (link) it says that it should be solved usingY
, but the topic (link) describes its solution usingZ
, so how much more correct ? or But I have the wrong option is not suitable, there are other options? That's why I allowed to mention about the manual and Google. On other issues I do not want to breed controversy. - Gromy
|
selected product name
andselected product id
, subscribe to changes, when you change one of them change and the other. - VladDclass Product
, add a property (not fields!) To it,public string Name
andpublic int Id
, and useDisplayMemberPath
in the combo box. - VladD