Shared Control Events??

Thread is closed for posting
2 posts, 0 answers
  1. Zach
    Zach avatar
    8 posts
    Member since:
    Feb 2008

    Posted 23 Nov 2009 Link to this post

    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?

    I'm currently using the Q2 controls.

  2. Victor
    Victor avatar
    1358 posts

    Posted 24 Nov 2009 Link to this post

    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,
    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.
Back to Top