This is a migrated thread and some comments may be shown as answers.

Shared Control Events??

1 Answer 57 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Zach
Top achievements
Rank 1
Zach asked on 23 Nov 2009, 07:51 PM

Is there some obvious explanation for this that I'm missing?
I'm experiencing what seems like control events being shared, perhaps by using a shared datasource.

I have a form with a RadListBox where the user can select an item in the listbox, and it loads details on the right. This is done by handling the listbox's SelectedIndexChanged event.

Now I'm transitioning to using a RadGridView instead so I can display extra information about the items.
To get it started, I simply added the grid to the form, added the necessary display columns, and without changing anything else, bound the grid's datasource to the same as the list. (No events set up on the grid yet. I just want to make sure the datasource is providing the information I need.)

What's weird though, is that selecting an item in the Grid ALSO selects that item in the listbox. The Listbox's SelectedIndexChanged event fires, and the sender is the Listbox (NOT the Grid, though I've only interacted with the Grid.)

The only thing that seems to 'link' the two controls basically looks like this:

form_Load(...) {
 // MyFactory.AListObject gets a List<display_object> from a data factory.
 // display_object is a simple object with a handful of display-able properties, no actual 'logic' in it.

  myListBox.DataSource = MyFactory.AListObject;
  myGrid.DataSource = MyFactory.AListObject;
}

Any idea why the grid's events are getting sent to the listbox?

P.S.
I'm currently using the Q2 controls.

1 Answer, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 24 Nov 2009, 08:57 AM
Hello Zach,

Thank you for writing. This is standard behavior in WinForms. List controls bound to the same data source will be automatically synchronized by a Microsoft component called CurrencyManager. If you want to decouple one of your controls you need to provide a custom BindingContext. For example if you want your RadGridView to be desynchronized you have to do this:
grid.BindingContext = new BindingContext();

Also please note that the standard Microsoft controls offer the same behavior by default.

Please write again if you have other questions.

Kind regards,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Zach
Top achievements
Rank 1
Answers by
Victor
Telerik team
Share this question
or