c# - Setting DataRow as ComboBox's value member -
I am filling out items in my combobox using XML file using a DataTable I am currently set to A column is the display box of the combo box and the second is a value member. Although it does not always work for me, because I have to set the selected item parameters, and the value member can not be unique.
I do not know whether the value in the table is a duplicate of the member or not, so I thought that I will keep the entire Dataraave as a member of the price of the combo box and then use the combo box. Selected Atom = (Detorov) some_data_row; To choose, and it will always choose the right combobox object.
How do I complete this? Is there a better way of doing this? I am open to suggestions, although it is very important that I can get both of them, I can show members and value to the member.
Thank you for your help!
Edit : I was not clear enough before, though, when I am asking that this is the best way, then I how this If I do not set the Valuembeber parameter, then the choice is Detourv Viv type ... Please note, I want to use the selected value parameter to select the item from the combo box, and if I try to do this Class I is then thrown exceptions set without value member.
If you list a list box to a datatable , You are actually binding it in the DataView which is the DataTable ( DataTable implies IListSource ) Represents>, and it returns a DataView ). You can not directly set SelectedItem for an DataRow example, you must set it to be a DataRowView example, unfortunately There is no easy way to get DataRowView from DataRow .
You will do better for all your interactions through your DataRowView . This will allow you to explicitly set SelectedItem .
You can not use the SelectedValue property, you must use the SelectedItem for it.
Comments
Post a Comment