c# - Binding empty dictionary to a listbox -


when try bind dictionary listbox argumentexception. cannot bind new value member.

i use following code. can 1 tell me wrong. because when enter row in dictionary working fine...

this.contactpersonenlistbox = new dictionary<int, string>();  lscontactpersonen.datasource = new bindingsource(this.contactpersonenlistbox, null); lscontactpersonen.displaymember = "value"; lscontactpersonen.valuemember = "key"; 

it doesn't make ton of sense bind empty dictionary since dictionary object doesn't report changes, adding item dictionary after setting data source won't show in listbox.

but rid of error, try setting this:

bindingsource b = new bindingsource(); b.datasource = this.contactpersonenlistbox; lscontactpersonen.displaymember = "value"; lscontactpersonen.valuemember = "key"; lscontactpersonen.datasource = b; 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -