Sure there is a procedure.
You could start with a simple data structure:
public class Country
{
public string Name { get; set; }
public IList<City> Cities { get; set; }
public Country()
{
Cities = new List<City>();
}
}
public class City { public string Name { get; set; } }
Then, instantiate this structure, e.g. into a property of your form...
Countries =
new List<Country>
{
new Country
{
Name = "Germany",
Cities =
{
new City {Name = "Berlin"},
new City {Name = "Hamburg"}
}
},
new Country
{
Name = "England",
Cities =
{
new City {Name = "London"},
new City {Name = "Birmingham"}
}
}
};
In your form, instantiate two Binding Sources (BS):
- The first BS binds to the Countries
property.
- The second BS binds to the first (DataSource = firstBS) and its DataMember should be "Cities".
Now you need two dropdowns:
- 1st: DataSource = first BS, DisplayMember = "Name"
- 2nd: DataSource = second BS, DisplayMember = "Name"
and you should be pretty much done.