Syncfusion.Grid.Windows
Members  Example 


Syncfusion.Windows.Forms.Grid Namespace : GridMoveCurrentCellDirectionEventArgs Class

GridMoveCurrentCellDirectionEventArgs Class

Provides data for the GridControlBase.MoveCurrentCellDirection which lets you customize how the current cell is moved when the user navigates through the grid with arrow keys.
Syntax
'Declaration
 
Public Class GridMoveCurrentCellDirectionEventArgs 
   Inherits GridQueryNextCurrentCellPositionEventArgs
'Usage
 
Dim instance As GridMoveCurrentCellDirectionEventArgs
public class GridMoveCurrentCellDirectionEventArgs : GridQueryNextCurrentCellPositionEventArgs 
Remarks
Used by GridControlBase.QueryNextCurrentCellPosition.

GridControlBase.QueryNextCurrentCellPosition occurs before the the current cell is moved into a specific direction. Normally, cells that are not marked as enabled with GridStyleInfo.Enabled will be skipped but you can hook into this mechanism by implementing a event handler for this event.

If you want to customize the behavior, 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;
            }
        }
             
    }
}
Inheritance Hierarchy

System.Object
   System.EventArgs
      Syncfusion.ComponentModel.SyncfusionEventArgs
         Syncfusion.ComponentModel.SyncfusionHandledEventArgs
            Syncfusion.Windows.Forms.Grid.GridQueryNextCurrentCellPositionEventArgs
               Syncfusion.Windows.Forms.Grid.GridMoveCurrentCellDirectionEventArgs

AssemblyVersion

Syncfusion.Grid.Windows: 17.3460.0.26

See Also