Hi, i am having a problem with combobox selectedindexchanged event. i have combobox as a member of a class i have created. it has an event handler for selectedindexchanged event for that combo box. now i have created two objects of that class and have a single dataset as datasource for both combo boxes. now when i change selection in one of them the event is raised twice for both combo boxes... what to do?? thanks in advance
On Thu, 3 Jul 2008 12:14:36 -0700 (PDT), aj wrote: >Hi, > >i am having a problem with combobox selectedindexchanged event. > >i have combobox as a member of a class i have created. it has an event >handler for selectedindexchanged event for that combo box. > >now i have created two objects of that class and have a single dataset >as datasource for both combo boxes. now when i change selection in one >of them the event is raised twice for both combo boxes... > > >what to do?? > >thanks in advance When you change one combobox, the other will change to match it. If you don't want that create a BindingSource and put it between the dataset and one of the comboboxes (you can create a BindingSource for both but it is not necessary). By default there is one CurrencyManager for all objects bound to the same source, and therefore one current position. When any object bound to the source changes the position in the source, all bound objects change their position. By putting a BindingSource between the source and one of the objects you are creating a separate CurrencyManager for that object. I'm not sure there is anything you can do about spurious SelectedIndexChanged events, combobox seems to sometimes fire that event multiple times.