Combobox selection changed event fires before the item is selected

4 posts, 0 answers
  1. Anj
    Anj avatar
    8 posts
    Member since:
    Jul 2010

    Posted 05 Jan 2011 Link to this post

    I have a grid view with a combo box column. I have subscribed to the selection changed event using this:
     this.AddHandler(RadComboBox.SelectionChangedEvent,
            new Telerik.Windows.Controls.SelectionChangedEventHandler(ComboBox_SelectionChanged));

    I notice that the selection changed event gets triggered even when I just click on the cell with the combo box. The drop down has not been opened and hence no selection has been made, but even then the event is triggered. The event is triggered again after the drop down opens and I make a selection. I think this is a bug. If it is not, then is there a way I can differentiate between the two triggers - one that happens on the click and the second which happens after the selection is made.
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 05 Jan 2011 Link to this post

    Hello Ana,

    This behavior is by design. What you can do to make sure which of the states you are in is to check if the RemovedItems collection is empty or not (whether this collection has no items):

    private void comboSelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
    {
        if (e.RemovedItems.Count != 0)
        {
            //this ensures a selection from the drop down is performed.
        }
    }  
     
    I hope that helps. 


    All the best,
    Maya
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. Zeeshan
    Zeeshan avatar
    12 posts
    Member since:
    Dec 2010

    Posted 12 Aug 2012 Link to this post

    Doesn't seems to work for me in the case when there is only one item in RadComboBox
  4. Zeeshan
    Zeeshan avatar
    12 posts
    Member since:
    Dec 2010

    Posted 12 Aug 2012 Link to this post

    I suppose the best way out here is to use DropdownClosed event instead of SelectionChanged event.
Back to Top