New to Telerik UI for WPF? Download free 30-day trial

Cancel Invalid Cell Edit on Click Outside of RadGridView

Environment

Product Version 2019.3.917
Product RadGridView for WPF

Description

How to cancel changes in invalid GridViewCell and exit edit mode when another control gets the focus.

Solution

To do this, you can subscribe for the GotFocus event of the control that should steal the focus from RadGridView and in the event handler, call the CancelEdit method of RadGridView.

<Grid> 
    <telerik:RadGridView x:Name="radGridView" /> 
    <telerik:RadButton x:Name="cancelEditButton" GotFocus="cancelEditButton_GotFocus"/> 
</Grid> 

private void cancelEditButton_GotFocus(object sender, RoutedEventArgs e) 
{ 
    this.radGridView.CancelEdit(); 
} 
In this article