Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding issue

Status
Not open for further replies.

DarkConsultant

Programmer
Dec 4, 2007
156
GB
Hi,

I am binding a combobox to a List(Of KeyValuePair(Of Integer,String)) using the code ...

Contacts is my list of kvp.

With cmbContacts
.Items.Clear
.DisplayMember = "Value"
.ValueMember = "Key"
.DataSource = New BindingSource(Contacts, Nothing)
End With

This works OK, populating the combobox with all of the KVP values.

However, I am not sure of the second BindingSource arg of Nothing (this is how it was on the example I found on the web).

When my code hits the BindingSource command I get three System.ArgumentNullException's. Although these do not affect the workings I am at a lost to explain them and would like to eradicate them.

Any ideas?

TIA

David

DarkConsultant

Live long and prosper \\//
 

Try this:

Code:
[red]Dim bsContacts As BindingSource
bsContacts = New BindingSource
bsContacts.DataSource = Contacts
[/red]
With cmbContacts
 .Items.Clear
 .DisplayMember = "Value"
 .ValueMember = "Key"
 .DataSource = [red]bsContacts[/red]
End With

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top