0
votes

Hi I have a dictionary which I bind to a bindingsource. I would like to display the keys in a listbox. So i add the bindingsource to the listbox and set the displaymember to "Key". This does not work. It gives me the tostring of the dictionary instead of the key string...

Code used:

        bs_directions.DataSource = bs_measurements;
        bs_directions.DataMember = "zielwertdict"; //(=Dictionary<string,list<object>>)

        listBox3.DataSource = bs_directions;
        listBox3.DisplayMember = "Key";

UPDATE: The bs_measurements is another list which is bound to another listbox. When I build the project the listBox3 displays the keys of the dictionary. When I change the item in the listbox which is bound to bs_measurement then listbox3 displays the dictionary.Tostring() things... very strange...

UPDATE 2: The objects contained in the bs_measurment list have a dictionary (zielwerdict) and a hashtable:

public class bs_measurementOBject
{
public string name;
public SortedDictionary<string,list>object>> zielwertlist;
public Hashtable block;
}
1
You may need to set the DataSource to a new BindingSource, i.e; bs_directions.DataSource = new BindingSource(bs_measurements, null); - Kestami
this does not change anything - benst

1 Answers

0
votes

In the above example bs_directions.DataMember has to be NULL