Xceed DataGrid for WPF v7.3 Documentation
Xceed.Wpf.DataGrid Assembly / Xceed.Wpf.DataGrid Namespace / Row Class / EditCanceled Event
Example


In This Topic
    EditCanceled Event (Row)
    In This Topic
    Raised after the EditCanceling event to signal that the edit process has been canceled.
    Syntax
    'Declaration
     
    Public Event EditCanceled As RoutedEventHandler
    'Usage
     
    Dim instance As Row
    Dim handler As RoutedEventHandler
     
    AddHandler instance.EditCanceled, handler
    public event RoutedEventHandler EditCanceled
    Event Data

    The event handler receives an argument of type RoutedEventArgs containing data related to this event. The following RoutedEventArgs properties provide information specific to this event.

    PropertyDescription
     
     
     
     
    Remarks
    The EditBeginning and EditEnding events are raised immediately after their respective BeginEdit and EndEdit methods are called to allow the process to be canceled. In the EditBeginning event, if the Cancel property of the CancelRoutedEventArgs received as a parameter is set to true, the cell or row that raised the event will be prevented from entering edit mode. Likewise, if Cancel is set to true in the EditEnding event, the cell or row will be prevented from exiting edit mode.
    Example
    All examples in this topic assume that the grid is bound to the Orders table of the Northwind database, unless stated otherwise.
    The following example demonstrates how to subscribe to the Cell.EditBeginning and EditBegun events as well as how to handle and cancel them.The following code provides the implementation of the EditBeginning and EditBegun event handlers.The following code provides the implementation of the EditBeginning and EditBegun event handlers.
    <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
       <Grid.Resources>
          <xcdg:DataGridCollectionViewSource x:Key="cvs_orders"
                                          Source="{Binding Source={x:Static Application.Current}, Path=Orders}" />    
       </Grid.Resources>
       <DockPanel>
          <StackPanel DockPanel.Dock="Top">
             <CheckBox x:Name="handledByRowCheckBox"
                       Content="Events are handled by the rows"
                       IsChecked="False" />
             <CheckBox x:Name="cancelBeginEdit"
                       Content="Cancel BeginEdit event"
                       IsChecked="False" />
          </StackPanel>
          <xcdg:DataGridControl x:Name="OrdersGrid"
                                ItemsSource="{Binding Source={StaticResource cvs_orders}}"
                                xcdg:Cell.EditBeginning="EditBeginning"
                                xcdg:Cell.EditBegun="EditBegun"/>
       </DockPanel>
    </Grid>
    Public Sub EditBeginning( ByVal sender As Object, ByVal e As CancelRoutedEventArgs )
       If Me.cancelBeginEdit.IsChecked = True Then
          e.Cancel = True
       End If
       If Me.handledByRowCheckBox.IsChecked = True Then
         e.Handled = True
       End If
       Debug.WriteLine( sender + ": EditBeginning" )
    End Sub
    
    Public Sub EditBegun( ByVal sender As Object, ByVal e As RoutedEventArgs )
       If Me.handledByRowCheckBox.IsChecked = True Then
         e.Handled = True
       End If
       Debug.WriteLine( sender + ": EditBegun" )
    End Sub
    public void EditBeginning( object sender, CancelRoutedEventArgs e )
    {
      e.Cancel = ( this.cancelBeginEdit.IsChecked == true );
      e.Handled = ( this.handledByRowCheckBox.IsChecked == true );
      Debug.WriteLine( sender + ": EditBeginning" );
    }
    
    public void EditBegun( object sender, RoutedEventArgs e )
    {
      e.Handled = ( this.handledByRowCheckBox.IsChecked ?? true );
      Debug.WriteLine( sender + ": EditBegun" );
    }
    Requirements

    Target Platforms: Windows 11, Windows, 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also