I have some problem with my combobox, I’m trying to fill it with some values from database, everything work fine, except the fact that last line of this code (with ValueMember in it) generate UnknownException in free translation it says that it cannot create a list of sub elements for the “table” field.
connection = new MySqlConnection(connectionString);
connection.Open();
MySqlDataAdapter mda = new MySqlDataAdapter(query, connection);
DataSet my_dataset = new DataSet("dataset");
mda.Fill(my_dataset);
connection.Close();
DataViewManager dvm_cb2 = my_dataset.DefaultViewManager;
my_combobox.DataSource = dvm_cb2;
my_combobox.DisplayMember = table + "." + name;
my_combobox.ValueMember = table + "." + my_id;
Any ideas, what could be the problem?
DisplayMember and ValueMember should be string repreentations of the object property
So for example if you had a collection of the following object
So you make a collection of the object
Then assign this and the properties to the combo box
That should work.