Binding a ComboBox

  • Thread starter Thread starter Blake Weaver
  • Start date Start date
B

Blake Weaver

Ok guys, I'm trying to bind a combobox two ways... I'm sure tons of you have
done it...
1) Fill it from a table
Currently setting the datasource and displaymember.
2) Display the appriopriate value based on the value in the selected row in
a datatable.
Have tried to bind the SelectedItem property and then tried the Text
property of the combobox.

I can do one or the other. If I try to do both, I get this ->
"System.Data.DataViewManagerListItemTypeDescriptor"

which shows up in the combobox when I run the application. Its not set in my
Text property or any other property that I can find. Whats going on???

Thanks,
Blake
 
Blake, can you show me your code?

If you set the datasoure..
myComboBox.DataSource = SomeDataSet

Then set the DisplayMember
myComboBox.DisplayMember = "Table1.SomeColumn"

Then set the Value member
myComboBox.ValueMember = "Table1.WhateverYouWantToSee"

This will bind it for you, but I don't believe that you can do this and then
go to the DataBindings.Add - If I remember correctly, it will yell at you.

Post the code and I'll see what I can do.

HTH,

Bill
 
I actually already found the problem. It was one of those that are so
obvious you easily overlook them...
It was a simple spelling error. I get too used to the compiler screaming at
me for those that I don't pay too much attention to them in strings. So when
I did the following:
cbCurrentStatus.DisplayMember = "CurrentStats.Name"

I misspelled the tablename. No error, just gave me funky results.
cbCurrentStatus.DisplayMember = "CurrentStatus.Name"

Thanks for the reply though.
Blake
 
Back
Top