We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize edit mode behavior of GridCell in SfDataGrid?

Platform: WPF |
Control: SfDataGrid |
Published Date: February 9, 2015 |
Last Revised Date: March 28, 2017
Tags: editing, columns

In SfDataGrid, you can directly go to the edit mode in Grid Cell by pressing any letter or digit as an input from the keyboard.

By default, SfDataGrid does not allow the Grid Cell to go to edit mode while pressing the Minus (-) key or any special character. You can overcome this behavior by customizing the SfDataGrid class, and overriding its OnTextInput () method.

Note: By default, GridTemplateColumn goes to edit mode while pressing the F2 key when you load the EditTemplate for it. No other letters or digits allow edit mode for GridTemplateColumn, GridCheckBoxColumn, GridImageColumn, GridHyperlinkColumn and GridUnboundColumn.

The following code example illustrates how to override the SfDataGrid class and customize the editing behavior in OnTextInput method.


In the above code example, the OnTextInput () method is fired when the input is received from the keyboard for Grid Column’s cell. With the help of CurrentRowColumnIndex in CurrentCellManager of SelectionController, you can get the current column from VisibleColumns collection that receives the input from keyboard.

The editing is skipped when the current column is GridTemplateColumn and it is already in edit mode. With the existing condition, you need to include the condition to allow negative number also.

The above customized SfDataGrid should be loaded in Xaml for implementing the editing behavior in Grid Cell. Refer the following code example.


You can refer to the following sample link for customizing the edit mode behavior of GridCell in SfDataGrid for WPF platform.

WPF: CustomizeEditMode_WPF

You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon