Syncfusion.Grid.Windows
Example 


MoveCurrentCellDirection Event (GridControlBase)

Occurs before the current cell is moved when the user navigates through the grid with arrow keys.
Syntax
'Declaration
 
<DescriptionAttribute("Occurs before the current cell is moved when the user navigates through the grid with arrow keys.")>
<CategoryAttribute("Behavior")>
Public Event MoveCurrentCellDirection As GridMoveCurrentCellDirectionEventHandler
'Usage
 
Dim instance As GridControlBase
Dim handler As GridMoveCurrentCellDirectionEventHandler
 
AddHandler instance.MoveCurrentCellDirection, handler
[Description("Occurs before the current cell is moved when the user navigates through the grid with arrow keys.")]
[Category("Behavior")]
public event GridMoveCurrentCellDirectionEventHandler MoveCurrentCellDirection
Event Data

The event handler receives an argument of type GridMoveCurrentCellDirectionEventArgs containing data related to this event. The following GridMoveCurrentCellDirectionEventArgs properties provide information specific to this event.

PropertyDescription
Gets or sets the column index. (Inherited from Syncfusion.Windows.Forms.Grid.GridQueryNextCurrentCellPositionEventArgs)
Gets or sets the GridDirectionType that specifies the direction of the current cell movement. (Inherited from Syncfusion.Windows.Forms.Grid.GridQueryNextCurrentCellPositionEventArgs)
Gets a value indicating whether to extend the current selection.  
Indicates whether the event has been handled and no further processing of the event should happen. (Inherited from Syncfusion.ComponentModel.SyncfusionHandledEventArgs)
Gets the number of cells to move.  
Gets or sets a value indicating whether if current cell can be moved in a specified direction. The resulting value. Set this to True if current cell can be moved in a specified direction; False if not. Don't forget to also set Handled to True. (Inherited from Syncfusion.Windows.Forms.Grid.GridQueryNextCurrentCellPositionEventArgs)
Gets or sets the row index. (Inherited from Syncfusion.Windows.Forms.Grid.GridQueryNextCurrentCellPositionEventArgs)
Remarks
If you want to customize the behavior, you should manually call CurrentCell.MoveTo from within the event handler and set e.Handled = True.
Example
The following example implements wrapping the current cell to the next row at the end of a row.
private void gridControl1_MoveCurrentCellDirection(object sender, GridMoveCurrentCellDirectionEventArgs e)
    {
        GridControlBase grid = sender as GridControlBase;
        GridModel gridModel = grid.Model;
        int row = e.RowIndex;
        int col = e.ColIndex;
        switch (e.Direction)
        {
            case GridDirectionType.Right:
            {
                col++;
                if (col > gridModel.ColCount)
                {
                    row++;
                    col = grid.LeftColIndex;
                }
            
                while (row < gridModel.RowCount)
                {
                    using (GridStyleInfo style = grid.GetViewStyleInfo(row, col))
                    {
                        if (style.Enabled)
                        {
                            e.Result = grid.CurrentCell.MoveTo(row, col);
                            e.Handled = true;
                            return;
                        }
            
                        col++;
                        if (col > gridModel.ColCount)
                        {
                            row++;
                            col = grid.LeftColIndex;
                        }
                    }
                }
                e.Handled = true;
                e.Result = false;
                break;
            }
            case GridDirectionType.Left:
            {
                col--;
                if (col == gridModel.Cols.HeaderCount)
                {
                    row--;
                    col = gridModel.ColCount;
                }
            
                while (row > gridModel.Rows.HeaderCount)
                {
                    using (GridStyleInfo style = grid.GetViewStyleInfo(row, col))
                    {
                        if (style.Enabled)
                        {
                            e.Result = grid.CurrentCell.MoveTo(row, col);
                            e.Handled = true;
                            return;
                        }
            
                        col--;
                        if (col == gridModel.Cols.HeaderCount)
                        {
                            row--;
                            col = gridModel.ColCount;
                        }
                    }
                }
                e.Handled = true;
                e.Result = false;
                break;
            }
        }
            
    }
}
AssemblyVersion

Syncfusion.Grid.Windows: 17.3460.0.14

See Also