Databinding to multicolumn combobox isn't working

1 posts, 0 answers
  1. Jerry
    Jerry avatar
    41 posts
    Member since:
    Mar 2012

    Posted 02 Oct 2013 Link to this post

    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.
Back to Top