Editing in MAUI DataGrid (SfDataGrid)

7 Jul 202624 minutes to read

The Syncfusion .NET MAUI DataGrid (SfDataGrid) control supports editing cell values by setting the SfDataGrid.AllowEditing property to true, the SfDataGrid.NavigationMode to Cell, and the SfDataGrid.SelectionMode to any value other than None.

To enable editing, follow the code example:

<syncfusion:SfDataGrid x:Name="dataGrid"
                       AllowEditing="True"
                       SelectionMode="Multiple"
                       NavigationMode="Cell"
                       ItemsSource="{Binding Orders}"/>
SfDataGrid dataGrid = new SfDataGrid();
OrderInfoViewModel orderInfoViewModel = new OrderInfoViewModel();
dataGrid.ItemsSource = orderInfoViewModel.Orders;
dataGrid.AllowEditing = true;
dataGrid.SelectionMode = DataGridSelectionMode.Multiple;
dataGrid.NavigationMode = DataGridNavigationMode.Cell;
this.Content = dataGrid;

DataGrid with editing

Column editing

To enable or disable editing for a specific column, you can simply set the DataGridColumn.AllowEditing property to true or false. Editable column types include DataGridTextColumn, DataGridNumericColumn, DataGridDateColumn, DataGridPickerColumn, and DataGridComboBoxColumn.

<syncfusion:SfDataGrid x:Name="dataGrid"
                       SelectionMode="Multiple"
                       NavigationMode="Cell"
                       ItemsSource="{Binding Orders}">
    <syncfusion:SfDataGrid.Columns>
        <syncfusion:DataGridTextColumn AllowEditing="True"
                                       MappingName="OrderID"/>
    </syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid>
SfDataGrid dataGrid = new SfDataGrid();
OrderInfoViewModel orderInfoViewModel = new OrderInfoViewModel();
dataGrid.ItemsSource = orderInfoViewModel.Orders;
dataGrid.SelectionMode = DataGridSelectionMode.Multiple;
dataGrid.NavigationMode = DataGridNavigationMode.Cell;
DataGridTextColumn column = new DataGridTextColumn();
column.MappingName = "OrderID";
column.AllowEditing = true;
dataGrid.Columns.Add(column);
this.Content = dataGrid;

Note: The DataGridColumn.AllowEditing property takes priority over SfDataGrid.AllowEditing.

Entering into edit mode

To enter edit mode, tap or double-tap the grid cell. Edit mode entry is controlled by the SfDataGrid.EditTapAction property. Supported values are:

  • DataGridTapAction.OnTap — Enter edit mode on single tap
  • DataGridTapAction.OnDoubleTap — Enter edit mode on double-tap (default)
<syncfusion:SfDataGrid x:Name="dataGrid"
                       AllowEditing="True"
                       NavigationMode="Cell"
                       SelectionMode="Multiple"
                       ItemsSource="{Binding Orders}"
                       EditTapAction="OnTap"/>
SfDataGrid dataGrid = new SfDataGrid();
OrderInfoViewModel orderInfoViewModel = new OrderInfoViewModel();
dataGrid.ItemsSource = orderInfoViewModel.Orders;
dataGrid.AllowEditing = true;
dataGrid.SelectionMode = DataGridSelectionMode.Multiple;
dataGrid.NavigationMode = DataGridNavigationMode.Cell;
dataGrid.EditTapAction = DataGridTapAction.OnTap; // For double tap , use DataGridTapAction.OnDoubleTap
this.Content = dataGrid;

Note: On iOS and Android, the keyboard will collapse when the editing grid cell loses focus.

Lost focus behavior

By default, when focus moves from the data grid to another control, the current cell value is not committed (default: DataGridLostFocusBehavior.None). To change this behavior and commit the current cell’s value when focus moves, set the SfDataGrid.LostFocusBehavior property to EndEditCurrentCell.

<syncfusion:SfDataGrid AllowEditing="True"
                       SelectionMode="Multiple"
                       NavigationMode="Cell"
                       LostFocusBehavior="EndEditCurrentCell"
                       ItemsSource="{Binding Orders}"/>
SfDataGrid dataGrid = new SfDataGrid();
OrderInfoViewModel orderInfoViewModel = new OrderInfoViewModel();
dataGrid.ItemsSource = orderInfoViewModel.Orders;
dataGrid.AllowEditing = true;
dataGrid.SelectionMode = DataGridSelectionMode.Multiple;
dataGrid.NavigationMode = DataGridNavigationMode.Cell;
dataGrid.LostFocusBehavior = DataGridLostFocusBehavior.EndEditCurrentCell;
this.Content = dataGrid;

Note: The LostFocusBehavior property applies only to DataGridNumericColumn and DataGridTextColumn. Other column types require explicit end-edit calls.

Support for IEditableObject

The SfDataGrid supports committing and rolling back changes at the row level when the underlying data object implements the IEditableObject interface.

Editing changes in a row will be committed only when tapping on next row.

The IEditableObject interface provides the following methods to capture editing:

  • BeginEdit: Called to begin editing on the underlying data object when cells in a row enter edit mode.
  • CancelEdit: Called when you cancel editing to discard the changes in a row since the last BeginEdit call.
  • EndEdit: Called when you move to the next row, tapping to commit changes in the underlying data object since the last BeginEdit call.

The following code snippet demonstrates a simple implementation of the IEditableObject interface:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using System.Linq;
using System.Diagnostics;

public class OrderInfo : INotifyPropertyChanged, IEditableObject
{
    public OrderInfo()
    {
    }

    #region private variables

    private int _orderID;
    private string _customerID;
    private string _city;
    private string _country;
    private string _product;

    #endregion

    #region Public Properties

    public int OrderID
    {
        get { return _orderID; }
        set
        {
            this._orderID = value;
            RaisePropertyChanged("OrderID");
        }
    }

    public string Customer
    {
        get { return _customerID; }
        set
        {
            this._customerID = value;
            RaisePropertyChanged("Customer");
        }
    }

    public string City
    {
        get { return _city; }
        set
        {
            this._city = value;
            RaisePropertyChanged("City");
        }
    }

    public string Country
    {
        get { return _country; }
        set
        {
            this._country = value;
            RaisePropertyChanged("Country");
        }
    }

    public string Product
    {
        get { return _product; }
        set
        {
            this._product = value;
            RaisePropertyChanged("Product");
        }
    }

    #endregion

    #region INotifyPropertyChanged implementation

    public event PropertyChangedEventHandler? PropertyChanged;

    private void RaisePropertyChanged(String Name)
    {
        if (PropertyChanged != null)
            this.PropertyChanged(this, new PropertyChangedEventArgs(Name));
    }

    private Dictionary<string, object> storedValues;


    public void BeginEdit()
    {
        this.storedValues = this.BackUp();
    }

    public void CancelEdit()
    {
        if (this.storedValues == null)
            return;

        foreach (var item in this.storedValues)
        {
            var itemProperties = this.GetType().GetTypeInfo().DeclaredProperties;
            var pDesc = itemProperties.FirstOrDefault(p => p.Name == item.Key);
            if (pDesc != null)
                pDesc.SetValue(this, item.Value);
        }
    }

    public void EndEdit()
    {
        if (this.storedValues != null)
        {
            this.storedValues.Clear();
            this.storedValues = null;
        }
        Debug.WriteLine("End Edit Called");
    }

    protected Dictionary<string, object> BackUp()
    {
        var dictionary = new Dictionary<string, object>();
        var itemProperties = this.GetType().GetTypeInfo().DeclaredProperties;
        foreach (var pDescriptor in itemProperties)
        {
            if (pDescriptor.CanWrite && pDescriptor.CanRead)
                dictionary.Add(pDescriptor.Name, pDescriptor.GetValue(this));
        }
        return dictionary;
    }

    #endregion
}

Note: The IEditableObject implementation above works with simple properties. For nullable types or complex nested objects, ensure your BackUp() and CancelEdit() methods properly handle null values and deep copying when necessary.

Editing events

The SfDataGrid invokes the following events during editing:

CurrentCellBeginEdit

The SfDataGrid.CurrentCellBeginEdit event occurs when the CurrentCell enters into edit mode. The DataGridCurrentCellBeginEditEventArgs has the following members that provides information for SfDataGrid.CurrentCellBeginEdit event:

  • Cancel: When this member set to true, the event is canceled and the CurrentCell does not enter into the edit mode.
  • RowColumnIndex: Gets the current row and column index of the DataGrid.
  • Column: Gets the Grid Column of the SfDataGrid.

To hook the SfDataGrid.CurrentCellBeginEdit event, follow the code example:

<syncfusion:SfDataGrid x:Name="dataGrid"
                       AllowEditing="True"
                       SelectionMode="Multiple"
                       NavigationMode="Cell"
                       CurrentCellBeginEdit="dataGrid_CurrentCellBeginEdit"
                       ItemsSource="{Binding Orders}">
</syncfusion:SfDataGrid>
private void dataGrid_CurrentCellBeginEdit(object sender, DataGridCurrentCellBeginEditEventArgs e)
{
    // Prevent editing of cell at RowColumnIndex(2,2).
    if (e.RowColumnIndex == new Syncfusion.Maui.GridCommon.ScrollAxis.RowColumnIndex(2, 2))
        e.Cancel = true;
}

CurrentCellEndEdit

The CurrentCellEndEdit event occurs when the CurrentCell exits the edit mode. The DataGridCurrentCellEndEditEventArgs has following members that provides information for SfDataGrid.CurrentCellEndEdit event:

  • RowColumnIndex: Gets the current row and column index of the DataGrid.
  • Cancel: When this member set to true, the event is canceled and the edited value is not committed in the underlying collection.

To hook the SfDataGrid.CurrentCellEndEdit event, follow the code example:

<syncfusion:SfDataGrid x:Name="dataGrid"
                       AllowEditing="True"
                       SelectionMode="Multiple"
                       NavigationMode="Cell"
                       CurrentCellEndEdit="dataGrid_CurrentCellEndEdit"
                       ItemsSource="{Binding Orders}">
</syncfusion:SfDataGrid>
private void dataGrid_CurrentCellEndEdit(object sender, DataGridCurrentCellEndEditEventArgs e)
{
    // Prevent editing from being committed for cell at RowColumnIndex(1,3).
    if (e.RowColumnIndex == new Syncfusion.Maui.GridCommon.ScrollAxis.RowColumnIndex(1, 3))
        e.Cancel = true;
}

Programmatic editing

Begin editing

The SfDataGrid allows you to programmatically edit a cell by calling the SfDataGrid.BeginEdit method. This method enters the particular cell into edit mode, enabling the editing of data programmatically. To programmatically edit a cell, refer to the code example below:

<syncfusion:SfDataGrid x:Name="dataGrid"
                       AllowEditing="True"
                       SelectionMode="Multiple"
                       NavigationMode="Cell"
                       Loaded="dataGrid_Loaded"
                       ItemsSource="{Binding Orders}">
</syncfusion:SfDataGrid>
private void dataGrid_Loaded(object sender, EventArgs e)
{
    //Edit the cell at 2nd row,2nd column programmatically
    this.dataGrid.BeginEdit(2, 2);
}

End editing

The SfDataGrid.EndEdit method allows you to programmatically conclude the editing process without parameters. When called, it commits the edited value of the current cell to the underlying collection and exits edit mode. To programmatically end the editing process, refer to the following code example:

this.dataGrid.EndEdit();

Cancel editing

The SfDataGrid.CancelEdit method allows you to programmatically cancel the editing process. When called, this method exits the edit mode of a cell without committing the edited value to the underlying collection. To programmatically cancel the editing process, use the code example provided:

this.dataGrid.CancelEdit();

Cancel editing operations

You can prevent editing using two event-based approaches:

Prevent cell from entering edit mode: Use the CurrentCellBeginEdit event to cancel editing before it starts:

<syncfusion:SfDataGrid x:Name="dataGrid"
                       AllowEditing="True"
                       SelectionMode="Multiple"
                       NavigationMode="Cell"
                       CurrentCellBeginEdit="dataGrid_CurrentCellBeginEdit"
                       ItemsSource="{Binding Orders}">
</syncfusion:SfDataGrid>
private void dataGrid_CurrentCellBeginEdit(object sender, DataGridCurrentCellBeginEditEventArgs e)
{
    // Prevent specific columns or rows from entering edit mode
    if (e.Column.MappingName == "OrderID" || e.RowColumnIndex.RowIndex == 2)
        e.Cancel = true;
}

Prevent edited value from being committed: Use the CurrentCellEndEdit event to discard changes instead of saving them:

<syncfusion:SfDataGrid x:Name="dataGrid"
                       AllowEditing="True"
                       SelectionMode="Multiple"
                       NavigationMode="Cell"
                       CurrentCellEndEdit="dataGrid_CurrentCellEndEdit"
                       ItemsSource="{Binding Orders}">
</syncfusion:SfDataGrid>
private void dataGrid_CurrentCellEndEdit(object sender, DataGridCurrentCellEndEditEventArgs e)
{
    // Discard changes for specific rows instead of committing them
    if (e.RowColumnIndex.RowIndex == 2)
        e.Cancel = true;
}

Undo and Redo an edit

The SfDataGrid allows you to undo or redo edits by setting the SfDataGrid.AllowUndoRedo to true (default: false). When enabled:

  • Windows/Mac Catalyst: Ctrl + Z (Undo), Ctrl + Y (Redo)
  • iOS/Mac Catalyst: Cmd + Z (Undo), Cmd + Y (Redo)

Note: Undo/Redo is supported on desktop platforms (Windows, Mac Catalyst). Mobile platform support may vary.

Refer to the following example to enable undo and redo actions:

<syncfusion:SfDataGrid x:Name="dataGrid"
                       ItemsSource="{Binding Orders}"
                       AllowEditing="True"
                       SelectionMode="Single"
                       AllowUndoRedo="True">
</syncfusion:SfDataGrid>
SfDataGrid dataGrid = new SfDataGrid();
OrderInfoViewModel viewModel = new OrderInfoViewModel();
dataGrid.ItemsSource = viewModel.Orders;
dataGrid.AllowEditing = true;
dataGrid.SelectionMode = DataGridSelectionMode.Single;
dataGrid.AllowUndoRedo = true;
this.Content = dataGrid;

MaxUndoRedoActions

The SfDataGrid.MaxUndoRedoActions property allows users to adjust the number of undo and redo actions in the DataGrid. Refer to the following example to set MaxUndoRedoActions:

<syncfusion:SfDataGrid x:Name="dataGrid"
                       ItemsSource="{Binding Orders}"
                       AllowEditing="True"
                       SelectionMode="Single"
                       AllowUndoRedo="True"
                       MaxUndoRedoActions="10">
</syncfusion:SfDataGrid>
SfDataGrid dataGrid = new SfDataGrid();
OrderInfoViewModel viewModel = new OrderInfoViewModel();
dataGrid.ItemsSource = viewModel.Orders;
dataGrid.AllowEditing = true;
dataGrid.SelectionMode = DataGridSelectionMode.Single;
dataGrid.AllowUndoRedo = true;
dataGrid.MaxUndoRedoActions = 10;
this.Content = dataGrid;

Undo Programmatically

The Undo method can be used to undo an edit in the DataGrid. To undo an edit using the Undo method, refer to the example below:

<Grid RowDefinitions="*,50">
    <syncfusion:SfDataGrid x:Name="dataGrid"
                           Grid.Row="0"
                           ItemsSource="{Binding Orders}"
                           AllowEditing="True"
                           SelectionMode="Single"
                           AllowUndoRedo="True">
    </syncfusion:SfDataGrid>
    <Button Grid.Row="1"
            Text="Undo"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            Clicked="Button_Clicked"/>
</Grid>
SfDataGrid dataGrid = new SfDataGrid();
OrderInfoViewModel viewModel = new OrderInfoViewModel();
dataGrid.ItemsSource = viewModel.Orders;
dataGrid.AllowEditing = true;
dataGrid.SelectionMode = DataGridSelectionMode.Single;
dataGrid.AllowUndoRedo = true;

Button button = new Button();
button.Text = "Undo";
button.HorizontalOptions = LayoutOptions.Center;
button.VerticalOptions = LayoutOptions.Center;
button.Clicked += Button_Clicked;

Grid grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Star });
grid.RowDefinitions.Add(new RowDefinition() { Height = 50 });
grid.Children.Add(dataGrid);
grid.Children.Add(button);
grid.SetRow(dataGrid, 0);
grid.SetRow(button, 1);
this.Content = grid;
private void Button_Clicked(object sender, EventArgs e)
{
    dataGrid.UndoRedoController.Undo();
}

Redo Programmatically

The Redo method can be used to redo an edit in the DataGrid. To redo an edit using the Redo method, refer to the example below:

<Grid RowDefinitions="*,50">
    <syncfusion:SfDataGrid x:Name="dataGrid"
                           Grid.Row="0"
                           ItemsSource="{Binding Orders}"
                           AllowEditing="True"
                           SelectionMode="Single"
                           AllowUndoRedo="True">
    </syncfusion:SfDataGrid>
    <Button Grid.Row="1"
            Text="Redo"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            Clicked="Button_Clicked"/>
</Grid>
SfDataGrid dataGrid = new SfDataGrid();
OrderInfoViewModel viewModel = new OrderInfoViewModel();
dataGrid.ItemsSource = viewModel.Orders;
dataGrid.AllowEditing = true;
dataGrid.SelectionMode = DataGridSelectionMode.Single;
dataGrid.AllowUndoRedo = true;

Button button = new Button();
button.Text = "Redo";
button.HorizontalOptions = LayoutOptions.Center;
button.VerticalOptions = LayoutOptions.Center;
button.Clicked += Button_Clicked;

Grid grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Star });
grid.RowDefinitions.Add(new RowDefinition() { Height = 50 });
grid.Children.Add(dataGrid);
grid.Children.Add(button);
grid.SetRow(dataGrid, 0);
grid.SetRow(button, 1);
this.Content = grid;
private void Button_Clicked(object sender, EventArgs e)
{
    dataGrid.UndoRedoController.Redo();
}

Clear History

The ClearHistory method can be used to clear the history of undo and redo stored in the respective stacks. To clear the history using the ClearHistory method, refer to the example below:

<Grid RowDefinitions="*,50">
    <syncfusion:SfDataGrid x:Name="dataGrid"
                           Grid.Row="0"
                           ItemsSource="{Binding Orders}"
                           AllowEditing="True"
                           SelectionMode="Single"
                           AllowUndoRedo="True">
    </syncfusion:SfDataGrid>
    <Button Grid.Row="1"
            Text="Clear History"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            Clicked="Button_Clicked"/>
</Grid>
SfDataGrid dataGrid = new SfDataGrid();
OrderInfoViewModel viewModel = new OrderInfoViewModel();
dataGrid.ItemsSource = viewModel.Orders;
dataGrid.AllowEditing = true;
dataGrid.SelectionMode = DataGridSelectionMode.Single;
dataGrid.AllowUndoRedo = true;

Button button = new Button();
button.Text = "Clear History";
button.HorizontalOptions = LayoutOptions.Center;
button.VerticalOptions = LayoutOptions.Center;
button.Clicked += Button_Clicked;

Grid grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Star });
grid.RowDefinitions.Add(new RowDefinition() { Height = 50 });
grid.Children.Add(dataGrid);
grid.Children.Add(button);
grid.SetRow(dataGrid, 0);
grid.SetRow(button, 1);
this.Content = grid;
private void Button_Clicked(object sender, EventArgs e)
{
    dataGrid.UndoRedoController.ClearHistory();
}

Undo and Redo Count

The number of undo and redo actions can be retrieved using UndoCount and RedoCount. Refer to the code below to set UndoCount and RedoCount:

<Grid RowDefinitions="50,*" ColumnDefinitions="*,*">
    <HorizontalStackLayout Grid.Row="0" Grid.Column="0" VerticalOptions="Center" HorizontalOptions="End">
        <Label Text="Undo Count"
               FontSize="16"
               FontAttributes="Bold"
               Margin="10,0"/>
        <Label x:Name="undoCountLabel"
               Text="{Binding Source={x:Reference dataGrid}, Path=UndoRedoController.UndoCount, StringFormat='{0}'}"
               FontSize="16"
               FontAttributes="Bold"
               Margin="10,0"/>
    </HorizontalStackLayout>
    <HorizontalStackLayout Grid.Row="0" Grid.Column="1" VerticalOptions="Center" HorizontalOptions="Start">
        <Label Text="Redo Count"
               FontSize="16"
               FontAttributes="Bold"
               Margin="10,0"/>
        <Label x:Name="redoCountLabel"
               Text="{Binding Source={x:Reference dataGrid}, Path=UndoRedoController.RedoCount, StringFormat='{0}'}"
               FontSize="16"
               FontAttributes="Bold"
               Margin="10,0"/>
    </HorizontalStackLayout>
    <syncfusion:SfDataGrid x:Name="dataGrid"
                           Grid.Row="1"
                           Grid.ColumnSpan="2"
                           ItemsSource="{Binding Orders}"
                           AllowEditing="True"
                           SelectionMode="Single"
                           AllowUndoRedo="True">
    </syncfusion:SfDataGrid>
</Grid>
SfDataGrid dataGrid = new SfDataGrid();
OrderInfoViewModel viewModel = new OrderInfoViewModel();
dataGrid.ItemsSource = viewModel.Orders;
dataGrid.AllowEditing = true;
dataGrid.SelectionMode = DataGridSelectionMode.Single;
dataGrid.AllowUndoRedo = true;

var undoLabelTitle = new Label();
undoLabelTitle.Text = "Undo Count";
undoLabelTitle.FontSize = 16;
undoLabelTitle.FontAttributes = FontAttributes.Bold;
undoLabelTitle.Margin = new Thickness(10, 0);

var undoCountLabel = new Label();
undoCountLabel.FontSize = 16;
undoCountLabel.FontAttributes = FontAttributes.Bold;
undoCountLabel.Margin = new Thickness(10, 0);
undoCountLabel.SetBinding(Label.TextProperty, new Binding(path: "UndoRedoController.UndoCount", source: dataGrid, stringFormat: "{0}"));

var undoLayout = new HorizontalStackLayout();
undoLayout.VerticalOptions = LayoutOptions.Center;
undoLayout.HorizontalOptions = LayoutOptions.End;
undoLayout.Children.Add(undoLabelTitle);
undoLayout.Children.Add(undoCountLabel);


var redoLabelTitle = new Label();
redoLabelTitle.Text = "Redo Count";
redoLabelTitle.FontSize = 16;
redoLabelTitle.FontAttributes = FontAttributes.Bold;
redoLabelTitle.Margin = new Thickness(10, 0);

var redoCountLabel = new Label();
redoCountLabel.FontSize = 16;
redoCountLabel.FontAttributes = FontAttributes.Bold;
redoCountLabel.Margin = new Thickness(10, 0);
redoCountLabel.SetBinding(Label.TextProperty, new Binding(path: "UndoRedoController.RedoCount", source: dataGrid, stringFormat: "{0}"));

var redoLayout = new HorizontalStackLayout();
redoLayout.VerticalOptions = LayoutOptions.Center;
redoLayout.HorizontalOptions = LayoutOptions.Start;
redoLayout.Children.Add(redoLabelTitle);
redoLayout.Children.Add(redoCountLabel);


Grid grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition() { Height = 50 });
grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Star });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star });
grid.Children.Add(dataGrid);
grid.Children.Add(undoLayout);
grid.Children.Add(redoLayout);
grid.SetRow(undoLayout, 0);
grid.SetColumn(undoLayout, 0);
grid.SetRow(redoLayout, 0);
grid.SetColumn(redoLayout, 1);
grid.SetRow(dataGrid, 1);
grid.SetColumnSpan(dataGrid, 2);
this.Content = grid;

Events in Undo Redo

Cell Undoing

The SfDataGrid.CellUndoing event occurs when the undo action is in progress for a cell. The DataGridUndoRedoEventArgs has the following members that provide information for the SfDataGrid.CellUndoing event:

  • Cancel: When this member is set to true, the event is canceled and the undo action for the cell does not occur.
  • RowIndex: Gets the row index of the undoing cell in the DataGrid.
  • ColumnIndex: Gets the column index of the undoing cell in the DataGrid.
  • Column: Gets the column of the DataGrid.
  • OldValue: Gets the old value of the undoing cell in the DataGrid.
  • NewValue: Gets the new value of the undoing cell in the DataGrid.

To hook the SfDataGrid.CellUndoing event, follow the code example:

<syncfusion:SfDataGrid x:Name="dataGrid"
                       ItemsSource="{Binding Orders}"
                       AllowEditing="True"
                       SelectionMode="Single"
                       AllowUndoRedo="True"
                       CellUndoing="DataGrid_CellUndoing">
</syncfusion:SfDataGrid>
SfDataGrid dataGrid = new SfDataGrid();
OrderInfoViewModel viewModel = new OrderInfoViewModel();
dataGrid.ItemsSource = viewModel.Orders;
dataGrid.AllowEditing = true;
dataGrid.SelectionMode = DataGridSelectionMode.Single;
dataGrid.AllowUndoRedo = true;
dataGrid.CellUndoing += DataGrid_CellUndoing;
this.Content = dataGrid;
private void DataGrid_CellUndoing(object sender, DataGridUndoRedoEventArgs e)
{
    if (e.ColumnIndex == 0)
    {
        e.Cancel = true;
    }
}

Cell Redoing

The SfDataGrid.CellRedoing event occurs when the redo action is in progress for a cell. To hook the SfDataGrid.CellRedoing event, follow the code example:

<syncfusion:SfDataGrid x:Name="dataGrid"
                       ItemsSource="{Binding Orders}"
                       AllowEditing="True"
                       SelectionMode="Single"
                       AllowUndoRedo="True"
                       CellRedoing="DataGrid_CellRedoing">
</syncfusion:SfDataGrid>
SfDataGrid dataGrid = new SfDataGrid();
OrderInfoViewModel viewModel = new OrderInfoViewModel();
dataGrid.ItemsSource = viewModel.Orders;
dataGrid.AllowEditing = true;
dataGrid.SelectionMode = DataGridSelectionMode.Single;
dataGrid.AllowUndoRedo = true;
dataGrid.CellRedoing += DataGrid_CellRedoing;
this.Content = dataGrid;
private void DataGrid_CellRedoing(object sender, DataGridUndoRedoEventArgs e)
{
    if (e.ColumnIndex == 0)
    {
        e.Cancel = true;
    }
}