Set Combobox Item from C# using Value in WPF -


My XML is a combobox in the window, I have a statistic that has two columns ID, name .

I can force that data in the Cambodox items using the code below.

  cbox.SelectedValuePath = "ID"; CBox.DisplayMemberPath = "name"; CBox.ItemsSource = dtable.DefaultView;  

What do I want, I want to choose specific item from c # by using id (not name) , then it's the first element of the combobox Select

  cobox.SelectedIndex = 0/1/2/3 / ...;  

If I use the code, it will pick any item in the combobox, but I use the Cambodia item use the ID

  CBox.Text = dtable.Rows [1] [1] .ostring ();  

You must use the selectedValue property. / P>

Try below

  cbox.SlectedValue = dtable.Rows [1] [0]. Ostring ();  

You can download samples working from here.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -