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.
Unfortunately, activation email could not send to your email. Please try again.

How to customize the Edit mode behavior of GridNumericColumn's Cell in SfDataGrid?

In SfDataGrid, you can edit the GridNumericColumn cell by pressing any key as input from the keyboard. But you cannot edit the GridNumericColumn cell by pressing the Minus sign (-) key. You can overcome this by deriving the GridCellNumericRenderer and override its ShouldGridTryToHandleKeyDown () method.

The following code example illustrates, how to derive the GridNumericColumn’s renderer and override the ShouldGridTryToHandleKeyDown () method in SfDataGrid.

C#

In the above code example, the ShouldGridTryToHandleKeyDown () method is fired for all key navigations, associated with GridNumericColumn. GridNumericColumn processes the input text in ProcessPreviewTextInput () method. You can customize the editing behavior of GridNumericColumn by specifying the required conditions within it.

The following code example illustrates the default behavior of ProcessPreviewTextInput ().

C#

In the above code example, editing is allowed when the pressed key value is equal to letters or numbers or numberpad otherwise, editing is skipped.

You can allow Edit mode for Minus sign (-) key by skipping its default condition as shown in the following code example.

C#

You can refer to the following code example to remove default the GridCellNumericRenderer and add the customized GridCellNumericRendererExt to the CellRenderers collection in SfDataGrid.

C#

 

Sample Link:

WRT

UWP

Article ID: Published Date: Last Revised Date: Platform: Control:
4020 02/13/2015 01/19/2016 WinRT SfDataGrid
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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.