Raised when the
BeginEdit method has been called to signal that the edit process is about to begin.
Syntax
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.
| XAML | Copy Code |
|---|
<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}" /> <Style TargetType="{x:Type xcdg:DataGridControl}"> <EventSetter Event="xcdg:Cell.EditBeginning" Handler="EditBeginning" /> <EventSetter Event="xcdg:Cell.EditBegun" Handler="EditBegun" /> </Style> <Style TargetType="{x:Type xcdg:DataRow}"> <EventSetter Event="xcdg:Cell.EditBeginning" Handler="EditBeginning" /> <EventSetter Event="xcdg:Cell.EditBegun" Handler="EditBegun" /> </Style> </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}}" /> </DockPanel> </Grid> |
The following code provides the implementation of the EditBeginning and EditBegun event handlers.
| Visual Basic | Copy Code |
|---|
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 |
The following code provides the implementation of the EditBeginning and EditBegun event handlers.
| C# | Copy Code |
|---|
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" );
} |
Remarks
Notes
Setting Cancel to true does not indicate that the event has been handled. In order to handle the event Handled must also be set to true.
Requirements
Supported Frameworks: Microsoft .NET Framework version 3.5
See Also