Home All Groups Group Topic Archive Search About

ComboBox binding to subset of another ComboBox

Author
13 Sep 2006 1:13 PM
Webbert
This is for a Windows Forms application...

I am wanting to set up binding once, if possible, for a second combobox that
contains filtered data based on the first.

I know I can capture the event of the first combobo and then bind the second
based on the value, but was hoping that there is an easier/better way.


Here is the scenario


class Car
{
   Guid carID;
   int year;
   string carName;
}

class Manufacturer
{
   Guid id;
   string name;
   List<Car> cars;
}

class MyCollection
{
   List<Manufacturer> makers;
}


private void MyControl_Load( object sender, EventArgs e )
{
    cboMaker.DisplayMember = "Name";
    cboMaker.ValueMember = "ID";
    cboMaker.DataSource = makers;

    cboCar.DisplayMember = "CarName";
    cboCar.ValueMember = "CarID";
    cboCar.DataSource = ???     <<<<<<<<<<<<<<<<
}


Thanks,
Dave

AddThis Social Bookmark Button