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
Post a Comment