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

Move to next Cell in a Column when Enter Button is pressed

I have a GridDataControl, in which I would like to know how to achieve following : 

There are three columns, only one of those is editable. I want user to be able to move to next cell in editable Column only when Enter is pressed.

How can I achieve this ?

1 Reply

SV Srinivasan Vasu Syncfusion Team July 10, 2017 09:58 AM UTC

Hi Rahul, 
 
Thanks for contacting Syncfusion support. 
 
We have checked your query and you can achieve your requirement by using SfDataGrid.PreviewKeyDown event. In sample, the Name column only editable and while pressing the Enter key the focus move to next cell (next row)of editable column. 
 
 
Please refer the below code example 
 
         this.grid.PreviewKeyDown += Grid_PreviewKeyDown;        
 
        private void Grid_PreviewKeyDown(object sender, KeyEventArgs e) 
        { 
            //Get the row index of current cell             
            var rowindex = grid.Model.CurrencyManager.CurrentCell.RowIndex; 
            if (rowindex < (grid.Model.RowCount - 1)) 
            { 
                //Get the column index of current cell 
                var colindex = grid.Model.CurrencyManager.CurrentCell.ColumnIndex; 
                if (e.Key == Key.Enter) 
                { 
                    //Need to move the selection into next row of current column  
                    grid.Model.CurrencyManager.CurrentCell.MoveTo(rowindex + 1, colindex); 
                    e.Handled = true; 
                } 
            } 
        } 
 
 
Please download the sample from the below location. 
 
 
 
Regards, 
Srinivasan 


Loader.
Up arrow icon