VBAHole22 Posted June 23, 2006 Posted June 23, 2006 Try this out at home: Create a class with a property that is a collection like List<Crap>. Then in a win form throw in like 10 comboboxes. When the form loads create an instance of your class(put some stuff in the collection) Set each combo's data source to the collection Change any combo box and they ALL CHANGE. I don't understand. I want to load each combo with a datasource but after that I want them to act independently of one another. Creating new instances of the collection doesn't solve this. Only creating a new instance of your class will make the combos act on their own. What am i missing here? Quote Wanna-Be C# Superstar
mskeel Posted June 23, 2006 Posted June 23, 2006 All the combo boxes are pointing to the same list which means they are all operating on the same chunk of memory. If you want them to act independently, you'll need to make a copy of the list for each ComboBox. Quote
VBAHole22 Posted June 23, 2006 Author Posted June 23, 2006 I sort of understand why that is happening but the solution I have is to go and create a new object for each combobox and that seems really wasteful. If there was a way I could copy the initial list and have it 'untie' itself that would work best but I don't know how to implement that. Quote Wanna-Be C# Superstar
Administrators PlausiblyDamp Posted June 23, 2006 Administrators Posted June 23, 2006 IIRC you need to look at the BindingContext of the object, by default they are all using the same one. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Denaes Posted June 29, 2006 Posted June 29, 2006 If you're using 2005, I believe you can set up multiple BindingSources' for your one collection and each will keep track of the the same list with different currency managers. Then you would bind the different BindingSources to the different Comboboxes. I know this works with datasets, but I just haven't tested this out with collections. If you're not using 2005, sorry I think you have to deal with currency managers and that was annoying. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.