Members  Example 

GridCurrentCell Class

Manages the current cell for a grid. Provides methods for activating, deactivating, and moving the current cell.
Object Model
GridCurrentCell ClassGridControlBase ClassGridCellModelBase ClassGridRangeInfo ClassGridCellRendererBase Class
Public Class GridCurrentCell 
   Inherits GridSubComponent
Dim instance As GridCurrentCell
public class GridCurrentCell : GridSubComponent 
Use the CurrentCell property of the GridControlBase class to get access to the GridCurrentCell instance associated with a grid.

The GridCurrentCell class raises events in the associated grid to give you a chance to adjust the current cell's behavior at any stage.

The following example shows how you can customize the behavior of the current cell and highlight the whole row of the current cell instead of just the current cell itself:
/// Current cell will be moving from one position to another.
protected override void OnCurrentCellMoving(GridCurrentCellMovingEventArgs e)
    e.Options |= GridSetCurrentCellOptions.BeginEndUpdate;
    // Instead of GridSetCurrentCellOptions.BeginEndUpdate we could also
    // sandwich the call in a Begin/EndUpdate pair ourselves ...
/// Completes a current cell's MoveTo operation indicating success.
protected override void OnCurrentCellMoved(GridCurrentCellMovedEventArgs e)
/// Completes a current cell's MoveTo operation indicating failure.
protected override void OnCurrentCellMoveFailed(GridCurrentCellMoveFailedEventArgs e)
/// Highlight the current row.
protected override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e)
    if (e.RowIndex > this.Model.Rows.HeaderCount && e.ColIndex > this.Model.Cols.HeaderCount
        && CurrentCell.HasCurrentCellAt(e.RowIndex))
        e.Style.Interior = new BrushInfo(SystemColors.Highlight);
        e.Style.TextColor = SystemColors.HighlightText;
        e.Style.Font.Bold = true;
/// Refresh the whole row for the old position of the current cell when it is moved to
/// a new row or when current cell is deactivated stand-alone.
protected override void OnCurrentCellDeactivated(GridCurrentCellDeactivatedEventArgs e)
    // Check if Deactivate is called stand-alone or called from MoveTo and row is moving.
    if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex)
        RefreshRange(GridRangeInfo.Row(e.RowIndex), GridRangeOptions.MergeAllSpannedCells);
/// Refresh the whole row for the new current cell position when the current cell is moved
/// to a new row or when current cell is activated stand-alone (and there was no activate current cell).
protected override void OnCurrentCellActivated(EventArgs e)
    // Check if Activate is called stand-alone or called from MoveTo and row is moving
    if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex
        || !CurrentCell.MoveFromActiveState)
        RefreshRange(GridRangeInfo.Row(CurrentCell.RowIndex), GridRangeOptions.MergeAllSpannedCells);
Inheritance Hierarchy



Syncfusion.Grid.Windows: 17.1460.0.47

See Also