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

Combobox selection changed event fires before the item is selected

3 Answers 591 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anj
Top achievements
Rank 1
Anj asked on 05 Jan 2011, 11:33 AM
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.

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 05 Jan 2011, 01:42 PM
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
0
Zeeshan
Top achievements
Rank 1
answered on 12 Aug 2012, 09:15 AM
Doesn't seems to work for me in the case when there is only one item in RadComboBox
0
Zeeshan
Top achievements
Rank 1
answered on 12 Aug 2012, 10:38 AM
I suppose the best way out here is to use DropdownClosed event instead of SelectionChanged event.
Tags
GridView
Asked by
Anj
Top achievements
Rank 1
Answers by
Maya
Telerik team
Zeeshan
Top achievements
Rank 1
Share this question
or