Back to Devexpress

GridOptionsNavigation.EnterMoveNextColumn Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridoptionsnavigation-858a6930.md

latest4.7 KB
Original Source

GridOptionsNavigation.EnterMoveNextColumn Property

Gets or sets whether the Enter key moves focus to the next cell.

Namespace : DevExpress.XtraGrid.Views.Grid

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
[DefaultValue(false)]
[XtraSerializableProperty]
public virtual bool EnterMoveNextColumn { get; set; }
vb
<DefaultValue(False)>
<XtraSerializableProperty>
Public Overridable Property EnterMoveNextColumn As Boolean

Property Value

TypeDefaultDescription
Booleanfalse

true if the Enter key moves focus to the next cell; otherwise, false.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to EnterMoveNextColumn
GridView

.OptionsNavigation .EnterMoveNextColumn

| | WinExplorerView |

.OptionsNavigation .EnterMoveNextColumn

|

Remarks

When the user presses the Enter key in an active editor, the changes are saved and the editor closes. Set the EnterMoveNextColumn property to false to automatically move focus to the next row cell and activate its editor. Note that focus is moved even if the next cell cannot be edited.

Multi-line editors use the Enter key to return the carriage, not to save changes. If the next cell uses the MemoEdit (or MemoExEdit) multi-line editor, set the AcceptsReturn (or AcceptsReturn) property to false to prevent the editor from handling the Enter key.

The New Item Row allows users to add a new row. To display the New Item Row, use the GridView.OptionsView.NewItemRowPosition property.

When a user presses the Enter key in this row, focus always moves to the next cell regardless of the EnterMoveNextColumn property value. When the user presses the Enter key in the last cell, a new row is created. To create a new row when the user presses the Enter key in any cell, not only in the last one, handle the ProcessGridKey event as shown below.

csharp
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;

gridControl.ProcessGridKey += GridControl_ProcessGridKey;

private void GridControl_ProcessGridKey(object sender, KeyEventArgs e) {
    var view = (sender as GridControl).MainView as GridView;
    if (e.KeyCode == Keys.Enter && view.IsNewItemRow(view.FocusedRowHandle)) {
        view.PostEditor();
        view.UpdateCurrentRow();
        e.Handled = true;
    }
}
vb
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid

AddHandler gridControl.ProcessGridKey, AddressOf GridControl_ProcessGridKey

Private Sub GridControl_ProcessGridKey(ByVal sender As Object, ByVal e As KeyEventArgs)
    Dim view = TryCast((TryCast(sender, GridControl)).MainView, GridView)
    If e.KeyCode = Keys.Enter AndAlso view.IsNewItemRow(view.FocusedRowHandle) Then
        view.PostEditor()
        view.UpdateCurrentRow()
        e.Handled = True
    End If
End Sub

See Also

AutoMoveRowFocus

GridOptionsNavigation Class

GridOptionsNavigation Members

DevExpress.XtraGrid.Views.Grid Namespace