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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to move a current cell focus to the first cell of the add new row in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl
Tags: addnewrow, focus

Adding new record

By default, the focus will be set to the newly added row when the record is added by using AddNewRecordRow. In order to set focus to the AddNewRecordRow after a new record is added, SourceListRecordChanged and TableControlCurrentCellKeyDown events can be used. In SourceListRecordChanged event, LastChangedRecord property can be used to avoid the focus moving to newly added row and TableControlCurrentCellKeyDown event, SetCurrent() method can be used to set the first column as CurrentCell.


//Event Triggering to avoid last focus if new record is added
this.gridGroupingControl1.SourceListRecordChanged += GridGroupingControl_SourceListRecordChanged;
//Event customization
 private void GridGroupingControl_SourceListRecordChanged(object sender,RecordChangedEventArgs e)
     if (e.Action == RecordChangedType.Added)
         //To avoid the last focus
         this.gridGroupingControl1.Table.LastChangedRecord = null;
//Event Triggering to set cursor on current cell
this.gridGroupingControl1.TableControlCurrentCellKeyDown += GridGroupingControl_TableControlCurrentCellKeyDown;
//Event Customization
private void GridGroupingControl_TableControlCurrentCellKeyDown(object sender,GridTableControlKeyEventArgs e)
        if (e.Inner.KeyCode == Keys.Enter &&
            this.gridGroupingControl1.Table.CurrentRecord is AddNewRecord)
            //To set focus for first cell of AddNewRecordRow provide first column name 



'Event Triggering to avoid last focus if new record is added
AddHandler Me.gridGroupingControl1.SourceListRecordChanged, AddressOf GridGroupingControl_SourceListRecordChanged
'Event customization
Private Sub GridGroupingControl_SourceListRecordChanged(ByVal sender As Object, ByVal e As RecordChangedEventArgs)
    If e.Action = RecordChangedType.Added Then
        'To avoid the last focus
        Me.gridGroupingControl1.Table.LastChangedRecord = Nothing
    End If
End Sub
'Event Triggering to set cursor on current cell
AddHandler Me.gridGroupingControl1.TableControlCurrentCellKeyDown, AddressOf GridGroupingControl_TableControlCurrentCellKeyDown
'Event Customization
Private Sub GridGroupingControl_TableControlCurrentCellKeyDown(ByVal sender As Object, ByVal e As GridTableControlKeyEventArgs)
        If e.Inner.KeyCode = Keys.Enter AndAlso TypeOf Me.gridGroupingControl1.Table.CurrentRecord Is AddNewRecord Then
            'To set focus for first cell of AddNewRecordRow provide first column name 
        End If
End Sub



Adding new record into GridGroupingControl


C#: AddNewRecordRow_Focus_CS

VB: AddNewRecordRow_Focus_VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
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.

Up arrow icon

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

Live Chat Icon For mobile