I am dealing with a single combobox instead of one that is part of a datagrid.
I need to bind it to a property of my object, but need to fill the list from another binding source. The problem is getting the combobox to have the correct intial value for the selelected item instead of just the 1st item in the binding source. There are so many combinations of settings with the databinding and the datasource that finding the right combination is not working.
Currently I can make it work manually by setting the index through code, but it would be good to make this type of binding work just thru design time binding.
Thanks
Heath
I am using a readonly list instead of a name value list. I tried variations of what you said, but it is not working out. I was able to improve a bit from your advice but I still need to manually set the intial selectedIndex of the combobox.
It is only about 6 lines of code to manually set the initial index. Time to move on and quit beating my head against the screen.
Thanks
jhw,
Strange - I've never had an issue with this.
I drag a BindingSource object on to my form and set its DataSource to my CSLA BusinessBase object. I then go to the Data Sources window - select my BusinessBase object, expand it, change the property I am concerned about to a ComboBox and drag it on to my form.
I add another BindingSource object and set its DataSource to my CSLA ReadOnlyListBase object.
Now I go back to the property ComboBox I just dragged on to the form, and change its DataSource value to be the name of the BindingSource object representing my CSLA ReadOnlyListBase object.
Since the ComboBox is "bound" to the BusinessBase object, the value listed in it gets set to that value; however, the dropdown itself is now all the values of the ReadOnlyListBase object.
Cheers,
Ken K
Ken
That is different than the way I have been doing it. I will give it a try.
Thanx
Ken
Turns out my problem was the order of setting datasources. Set the data souce for the bound object binding source last.
Copyright (c) Marimer LLC