Sunday, 15 January 2012

c# - Load a ComboBox from Dictionary with BindingSource gives an ArgumentNullException -


I am trying to start a combo box from the following:

  dictionary & Lt; String, int & gt; TestDictionary = New Dictionary & lt; String, int & gt; {{"Text1", 1}, {"text2", 2}, {"text3", 3}}; TestComboBox.DataSource = New binding source (TestDictionary, blank);  

But it throws the following exception:

 Logic

Why are you bound to make it a null? You want this man

  Binding source (iCotNair)  

this is not a

  binding source (object, string Public Binding Source (Object Datasource, String Datamember)  

From the

Use your data base in Cambodia Done through.

  dataMember type:  

to bind specific column or list names to the System.String data source or give it the proper name.

UPD / Correction:

According to the above comment, you need to map these two:

  testComboBox.DisplayMember = "value" ; TestComboBox.ValueMember = "key";  

No comments:

Post a Comment