From a893db24af22020caf0a0a038b4fe8fa971ad3e4 Mon Sep 17 00:00:00 2001 From: Sreemon Premkumar M Date: Thu, 14 Aug 2025 11:16:56 +0530 Subject: [PATCH 1/3] ES-975464 - Resolve the ReadMe Length Issues in the Public Repositories --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9570ec2..bde54d7 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,7 @@ # how-to-change-the-Enter-key-behavior-in-winforms-datagrid -This example illustrates how-to-change-the-Enter-key-behavior-in-winforms-datagrid + +This example illustrates how to change the Enter key behavior in [WinForms DataGrid](https://www.syncfusion.com/winforms-ui-controls/datagrid). + +When pressing the Enter key, the current cell will be moved to the next row in [DataGrid](https://www.syncfusion.com/winforms-ui-controls/datagrid), by default. You can change this behavior like, Tab key that moves the current cell to the next cell on the same row by writing a custom SelectionController and overriding the [HandleKeyOperations](https://help.syncfusion.com/cr/windowsforms/Syncfusion.WinForms.DataGrid.Interactivity.SelectionControllerBase.html#Syncfusion_WinForms_DataGrid_Interactivity_SelectionControllerBase_HandleKeyOperations_System_Windows_Forms_KeyEventArgs_) method, which Handles selection when any of the Key operations such as Up, Down, Left, Right, Enter, etc., are performed in [DataGrid](https://www.syncfusion.com/winforms-ui-controls/datagrid). + +KB article: https://support.syncfusion.com/kb/article/8625/how-to-change-the-enter-key-behavior-in-winforms-datagrid-sfdatagrid \ No newline at end of file From d54e4f0665c004d09e175c72cb57f7d7170d3149 Mon Sep 17 00:00:00 2001 From: SreemonPremkumarMuthukrishnan Date: Wed, 22 Oct 2025 00:38:56 +0530 Subject: [PATCH 2/3] ES-975464 - Committed the changes --- README.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bde54d7..aba3f1e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,63 @@ -# how-to-change-the-Enter-key-behavior-in-winforms-datagrid +# How to Change the Enter Key Behavior in WinForms DataGrid? -This example illustrates how to change the Enter key behavior in [WinForms DataGrid](https://www.syncfusion.com/winforms-ui-controls/datagrid). +This example illustrates how to change the Enter key behavior in [WinForms DataGrid](https://www.syncfusion.com/winforms-ui-controls/datagrid) (SfDataGrid). -When pressing the Enter key, the current cell will be moved to the next row in [DataGrid](https://www.syncfusion.com/winforms-ui-controls/datagrid), by default. You can change this behavior like, Tab key that moves the current cell to the next cell on the same row by writing a custom SelectionController and overriding the [HandleKeyOperations](https://help.syncfusion.com/cr/windowsforms/Syncfusion.WinForms.DataGrid.Interactivity.SelectionControllerBase.html#Syncfusion_WinForms_DataGrid_Interactivity_SelectionControllerBase_HandleKeyOperations_System_Windows_Forms_KeyEventArgs_) method, which Handles selection when any of the Key operations such as Up, Down, Left, Right, Enter, etc., are performed in [DataGrid](https://www.syncfusion.com/winforms-ui-controls/datagrid). +When pressing the Enter key, the current cell will be moved to the next row in DataGrid, by default. You can change this behavior like, Tab key that moves the current cell to the next cell on the same row by writing a custom [RowSelectionController](https://help.syncfusion.com/cr/windowsforms/Syncfusion.WinForms.DataGrid.Interactivity.RowSelectionController.html) overriding method [HandleKeyOperations](https://help.syncfusion.com/cr/windowsforms/Syncfusion.WinForms.DataGrid.Interactivity.SelectionControllerBase.html#Syncfusion_WinForms_DataGrid_Interactivity_SelectionControllerBase_HandleKeyOperations_System_Windows_Forms_KeyEventArgs_). -KB article: https://support.syncfusion.com/kb/article/8625/how-to-change-the-enter-key-behavior-in-winforms-datagrid-sfdatagrid \ No newline at end of file +### C# + +``` csharp +public Form1() +{ + InitializeComponent(); + this.sfDataGrid.SelectionController = new CustomSelectionController(sfDataGrid); +} + +public class CustomSelectionController : Syncfusion.WinForms.DataGrid.Interactivity.RowSelectionController +{ + SfDataGrid DataGrid; + + public CustomSelectionController(SfDataGrid sfDataGrid) : base(sfDataGrid) + { + this.DataGrid = sfDataGrid; + } + + protected override void HandleKeyOperations(KeyEventArgs args) + { + if (args.KeyCode == Keys.Enter) + { + KeyEventArgs arguments = new KeyEventArgs(Keys.Tab); + base.HandleKeyOperations(arguments); + return; + } + base.HandleKeyOperations(args); + } +} +``` + +### VB + +``` vb +Public Sub New() + InitializeComponent() + Me.sfDataGrid.SelectionController = New CustomSelectionController(sfDataGrid) +End Sub + +Public Class CustomSelectionController Inherits Syncfusion.WinForms.DataGrid.Interactivity.RowSelectionController + + Private DataGrid As SfDataGrid + Public Sub New(ByVal sfDataGrid As SfDataGrid) + MyBase.New(sfDataGrid) + Me.DataGrid = sfDataGrid + End Sub + + Protected Overrides Sub HandleKeyOperations(ByVal args As KeyEventArgs) + If args.KeyCode = Keys.Enter Then + Dim arguments As New KeyEventArgs(Keys.Tab) + MyBase.HandleKeyOperations(arguments) + Return + End If + MyBase.HandleKeyOperations(args) + End Sub +End Class +``` \ No newline at end of file From ccc3919b3b4af90d489a825f6252775c505b4c8d Mon Sep 17 00:00:00 2001 From: SreemonPremkumarM Date: Wed, 22 Oct 2025 22:33:58 +0530 Subject: [PATCH 3/3] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aba3f1e..54e1f58 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ End Sub Public Class CustomSelectionController Inherits Syncfusion.WinForms.DataGrid.Interactivity.RowSelectionController Private DataGrid As SfDataGrid + Public Sub New(ByVal sfDataGrid As SfDataGrid) MyBase.New(sfDataGrid) Me.DataGrid = sfDataGrid @@ -60,4 +61,4 @@ Public Class CustomSelectionController Inherits Syncfusion.WinForms.DataGrid.Int MyBase.HandleKeyOperations(args) End Sub End Class -``` \ No newline at end of file +```