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.
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 ().
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.
You can refer to the following code example to remove default the GridCellNumericRenderer and add the customized GridCellNumericRendererExt to the CellRenderers collection in SfDataGrid.
This page will automatically be redirected to the sign-in page in 10 seconds.