This is a migrated thread and some comments may be shown as answers.

Databinding to multicolumn combobox isn't working

0 Answers 106 Views
MultiColumn ComboBox
This is a migrated thread and some comments may be shown as answers.
Jerry
Top achievements
Rank 1
Jerry asked on 02 Oct 2013, 01:09 PM
I have tried binding to a multicolumn combobox with no success.  It works fine with checkboxes and textboxes.  Here is the code i'm using

DataTable dtAct = new DataTable();
BindingSource bsAct = new BindingSource();
 
//dtAct is populated by a query from my db.
 
bsAct.DataSource = dtAct;
bsAct.Position = 0;
 
 
/*
GetSupCat() returns
value text
1     Test1
2     Test2
3     Test3
*/
 
 
cbMainActSupCat.DataSource = GetSupCat(); //Procedure that returns a datatable with the data to populate the combobox
cbMainActSupCat.DisplayMember = "value";
cbMainActSupCat.ValueMember = "value";
cbMainActSupCat.DataBindings.Add(new Binding("SelectedItem", bsAct, "SupCat"));     
 
//SupCat comes from bindingsource from my original query

The combobox should show the value of "SupCat".  When I bind it to a textbox it shows me the number 2, but the combo still shows the first  item 1.

Thank you for any help you can give me.  This is an important part of my application.

No answers yet. Maybe you can help?

Tags
MultiColumn ComboBox
Asked by
Jerry
Top achievements
Rank 1
Share this question
or