Multiple Combobox with the same EntityCollection

Posts   
 
    
Anthony
User
Posts: 155
Joined: 04-Oct-2006
# Posted on: 14-Jun-2008 02:55:28   

I have an application where i load all my lists at startup then i bind them as datasources for comboboxes. I have found that if i bind a collection to 2 comboboxes then the selected item is kept the same on both comboboxes. Any reason why the selected item is being tracked through both?

Do i have to clone the collection or is their some settings?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 14-Jun-2008 03:44:18   
  • Could you please post the code snippet where you are binding?

  • WinForms or ASP.Net?

  • Binding to a EntityCollection directly or via other control (LLBLGenProDataSource, some BindingSource)?

  • LLBLGenPro version?

David Elizondo | LLBLGen Support Team
Anthony
User
Posts: 155
Joined: 04-Oct-2006
# Posted on: 14-Jun-2008 04:51:30   

winforms,llblgen v2.5,dotnet2

    Me.cmboUser.DisplayMember = "Name"
    Me.cmboUser.ValueMember = "UserId"
    Me.cmboUser.DataSource = comm.tblUserEntityCollection
    Me.cmboUser.SelectedIndex = -1

    Me.ComboBoxActivityAssignedUser.DisplayMember = "Name"
    Me.ComboBoxActivityAssignedUser.ValueMember = "UserId"
    Me.ComboBoxActivityAssignedUser.DataSource = comm.tblUserEntityCollection
    Me.ComboBoxActivityAssignedUser.SelectedIndex = -1

thanks

arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 14-Jun-2008 12:56:32   

Me.cmboUser.DataSource = comm.tblUserEntityCollection

You might try binding to a view of the collection instead.

Me.cmboUser.DataSource = comm.tblUserEntityCollection.CreateView()

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39872
Joined: 17-Aug-2003
# Posted on: 15-Jun-2008 11:54:59   

Arschr is right, you have to bind via a new view to each combobox. If you don't do that, and bind the collection to the comboboxes, the same defaultview is bound to both comboboxes. If you create a new view each time, the binding is different per combobox simple_smile

Frans Bouma | Lead developer LLBLGen Pro