Class GridMoveCurrentCellDirectionEventArgs
Holds data for the MoveCurrentCellDirection which lets you customize how the current cell is moved when the user navigates through the grid with arrow keys.
Inheritance
Inherited Members
Namespace: Syncfusion.Windows.Controls.Grid
Assembly: Syncfusion.Grid.Wpf.dll
Syntax
public class GridMoveCurrentCellDirectionEventArgs : GridQueryNextCurrentCellPositionEventArgs
Remarks
Used by QueryNextCurrentCellPosition.
QueryNextCurrentCellPosition occurs before the the current cell is moved into a specific direction. Normally, cells that are not marked as enabled with 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;
Examples
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;
}
}
}
}
Constructors
GridMoveCurrentCellDirectionEventArgs(GridDirectionType, Int32, Boolean, Int32, Int32, RoutedEvent, Object)
Initializes the object.
Declaration
public GridMoveCurrentCellDirectionEventArgs(GridDirectionType direction, int numCells, bool extendSelection, int rowIndex, int colIndex, RoutedEvent routedEvent, object source)
Parameters
Type | Name | Description |
---|---|---|
GridDirectionType | direction | The GridDirectionType that specifies the direction of the current cell movement. |
System.Int32 | numCells | The number of cells to move. |
System.Boolean | extendSelection | Extends the current selection. |
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
System.Windows.RoutedEvent | routedEvent | |
System.Object | source |
Properties
ExtendSelection
Specifies whether to extend the current selection.
Declaration
[TraceProperty(true)]
public bool ExtendSelection { get; }
Property Value
Type |
---|
System.Boolean |
NumCells
The number of cells to move.
Declaration
[TraceProperty(true)]
public int NumCells { get; }
Property Value
Type |
---|
System.Int32 |