Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
Databinding of Two (or even more) ultracombos
posted

Hi there,

i have a small problem and i'm looking for the best way to solve it.

Here is a short example i have a bindinglist of possiblecountries. (germany, belgium, france etc ...)

Each Country-Entity has a BindingList of cities (of this country).

For example munich, berlin, frankfurt for germany.

paris, marseille, Lyon for france.

I have an editObject (Customer) whith two string properties country and city.

Now i want to make a dialog with two ultracombo. The first one for showing and selecting the countriy where a customer lives and a second one for editing the city.

and the second combobox should be bound to the list of the cities which are selected by the first combobox.

so the datasource of the city-combo changes when the users changes the country.

'til now i have solved the problem that i connect to the valuechanged event of the first combo-Box and rebind the second combo each time the user changes the city ...

Is this o.k.? or is there a better way to say only once that the datasource of the second combo is the selected item of the first combo?

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi,

    There's nothing wrong with doing it that way. The only potential problem you might encounter with this approach is that the currently-selected city might not be valid for the country when the country changes.

    For example, if the user chooses "Germany" and then "Berlin" and the switches the country to "France", "Berlin" is no longer a valid choice, so you should probably null out the value of the city combo any time the country combo is changed (in addition to re-binding the list).

    Another potential way to implement this would be to populate the city combo up-front with a list of all possible cities. Then, in the ValueChanged of the country combo you apply a ColumnFilter to the city combo to filter out everything except the cities that are valid for the current country. Frankly, I think your original approach is better and this approach doesn't really gain you much unless there are cases where you need to maintain an invalid city selection.

Children
No Data