Edit this page

Handle SelectionChanged for GridViewComboBoxColumn

GridViewComboBoxColumn does not expose a SelectionChanged event itself. In case you need such an event to implement your additional logic, you can handle the SelectionChanged event of its editing element (RadComboBox). For example the code to do so is available bellow:

[C#] Example 1: Add a handler for the SelectionChanged event

this.AddHandler(RadComboBox.SelectionChangedEvent, new System.Windows.Controls.SelectionChangedEventHandler(OnSelectionChanged));

[VB.NET] Example 1: Add a handler for the SelectionChanged event

Me.AddHandler(RadComboBox.SelectionChangedEvent, New System.Windows.Controls.SelectionChangedEventHandler(AddressOf OnSelectionChanged))

[C#] Example 2: Handle the SelectionChanged event

private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if (e.RemovedItems.Count > 0)
        {
            //your code here
        }
    }

[VB.NET] Example 2: Handle the SelectionChanged event

Private Sub OnSelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs)
    If e.RemovedItems.Count > 0 Then
        'your code here
    End If
End Sub

You can see that with the code snippet above I check if there are any items being unselected (through the RemovedItems.Count). This ensures the event will not be handled on initial loading when a default item has been selected.

See Also