Current filter:
                                You should refresh the page.
                                0
                                  • How to force the grid to focus the next row when I press the Tab or Enter key, while then last column cell is focused?

                                You must  log in  or  register  to leave comments

                                1 Solution

                                0

                                XtraGrid 2 and 3 provide an option to support this behavior: the AutoMoveRowFocus option of the GridView.OptionsNavigation property. The option is activated by default.

                                In XtraGrid 1 this can be implemented using the ProcessGridKey event of your grid control. Simply check which keys have been pressed via the e parameter passed to the event. Use the sender parameter to obtain your GridControl object, its KeyboardFocusView property to access the view which receives keystrokes and the view’s FocusedColumn and FocusedRowHandle properties to determine which cell is currently focused.

                                	
                                [C#]
                                private void gridControl_ProcessGridKey(object sender, System.Windows.Forms.KeyEventArgs e){ DevExpress.XtraGrid.GridControl gc = (DevExpress.XtraGrid.GridControl)sender; DevExpress.XtraGrid.Views.Grid.GridView gv = (DevExpress.XtraGrid.Views.Grid.GridView)gc.KeyboardFocusView; if(!e.Shift && (e.KeyCode == System.Windows.Forms.Keys.Tab) && (gv.FocusedColumn == gv.GetVisibleColumn(gv.VisibleColumnCount -1))){ gv.FocusedColumn = gv.GetVisibleColumn(0); if (gv.FocusedRowHandle != gv.RowCount - 1) gv.FocusedRowHandle += 1; gv.ShowEditor(); e.Handled = true; } if(e.Shift && (e.KeyCode == System.Windows.Forms.Keys.Tab) && (gv.FocusedColumn == gv.GetVisibleColumn(0))){ gv.FocusedColumn = gv.GetVisibleColumn(gv.VisibleColumnCount -1); if (gv.FocusedRowHandle != 0) gv.FocusedRowHandle -= 1; gv.ShowEditor(); e.Handled = true; } }

                                See Also:
                                How to move focus to the next control when the Tab key is pressed and the last grid cell is focused

                                You must  log in  or  register  to leave comments