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.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

131406 Jul 7,2017 10:42 AM Jul 10,2017 05:58 AM WPF 1
loading
Tags: GridDataControl
Rahul Makwana
Asked On July 7, 2017 10:42 AM

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 ?

Srinivasan Vasu [Syncfusion]
Replied On July 10, 2017 05:58 AM

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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;