cancel selectionchanged on RadMulticolumncombobox

1 Answer 18 Views
MultiColumnComboBox
Stijn
Top achievements
Rank 1
Stijn asked on 07 Apr 2022, 01:38 PM

I'm not sure if it's possible but what i want to achieve is when a user changes the selecteditem they get a question it they are sure if they want to change the selection. If they say ok, no problem, but in the other cases i want to 'cancel' the selectionchanged and keep the currently selecteditem.

I can stop the event with the e.handled = true but it still changes the selected item.

Is there anything i can do to reach this behaviour?
I've seens there is no cancel on the evenArgs so that's not an option.

 

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 12 Apr 2022, 08:36 AM

Hello Stijn,

To achieve the desired result, you could subscribe to the SelectionChanging event of the RadGridView element, which is shown when the drop-down menu is opened. This could be done by adding a Style with TargetType="RadGridView" to the Resources collection of the MultiColumnComboBox element, with an EventSetter for the mentioned property. In the generated method, you could create a new MessageBoxResult instance, and if the returned value of the MessageBox.Show method is MessageBoxResult.No, set the e.Cancel property to True. By setting this property to true, the selection will be canceled.

The following code snippets show this suggestion's implementation:

<telerik:RadMultiColumnComboBox.Resources>
    <Style TargetType="telerik:RadGridView">
        <EventSetter Event="SelectionChanging" Handler="RadGridView_SelectionChanging"/>
    </Style>
</telerik:RadMultiColumnComboBox.Resources>
private void RadGridView_SelectionChanging(object sender, SelectionChangingEventArgs e)
{
    var gridView = (RadGridView)sender;

    MessageBoxResult result = MessageBox.Show("Continue change?", "Change Confirmation", MessageBoxButton.YesNo);

    if (result == MessageBoxResult.No)
    {
        e.Cancel = true;
        return;
    }

    gridView.SelectedItem = e.AddedItems[0];
}

With that said, I have attached a sample project, so, could you give it a try?

Regards,
Stenly
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Stijn
Top achievements
Rank 1
commented on 12 Apr 2022, 08:47 AM

i found an alternative workaround but i'll sure give this a go as this is a much cleaner and faster approach
Tags
MultiColumnComboBox
Asked by
Stijn
Top achievements
Rank 1
Answers by
Stenly
Telerik team
Share this question
or