Syncfusion.Grid.Windows
Members  Example 


Syncfusion.Windows.Forms.Grid Namespace : GridPrepareViewStyleInfoEventArgs Class

GridPrepareViewStyleInfoEventArgs Class

Provides data about the cancelable GridControlBase.PrepareViewStyleInfo event.
Object Model
GridPrepareViewStyleInfoEventArgs ClassGridStyleInfo Class
Syntax
'Declaration
 
Public NotInheritable Class GridPrepareViewStyleInfoEventArgs 
   Inherits GridCellCancelEventArgs
'Usage
 
Dim instance As GridPrepareViewStyleInfoEventArgs
public sealed class GridPrepareViewStyleInfoEventArgs : GridCellCancelEventArgs 
Remarks
GridPrepareViewStyleInfoEventArgs is a custom event argument class used by the GridControlBase.PrepareViewStyleInfo event to allow custom formatting of a cell by changing its style object. Set the Cancel property true if you want to avoid calling the associated cell renderer's object GridCellRendererBase.OnPrepareViewStyleInfo method.

Changes made to the style object will not be saved in the grid nor cached. This event is called every time a portion of the grid is repainted and the specified cell belongs to the invalidated region of the window that needs to be redrawn.

Changes to the style object done at this time will also not be reflected when accessing cells though the models indexer. See QueryCellInfo.

Do not change base style or cell type at this time.

Example
The following example shows how you can customize the behavior of the current cell and highlight the whole row 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;
}
             
/// 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;
    }
    base.OnPrepareViewStyleInfo(e);
}
             
/// 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);
    }
    base.OnCurrentCellDeactivated(e);
}
             
/// 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 activated current cell).
protected override void OnCurrentCellActivated(EventArgs e)
{
    // Check if Activate is called stand-alone or called from MoveTo and row is moving
    base.OnCurrentCellActivated(e);
    if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex
        || !CurrentCell.MoveFromActiveState)
    {
        RefreshRange(GridRangeInfo.Row(CurrentCell.RowIndex), GridRangeOptions.MergeAllSpannedCells);
    }
}
Inheritance Hierarchy

System.Object
   System.EventArgs
      System.ComponentModel.CancelEventArgs
         Syncfusion.ComponentModel.SyncfusionCancelEventArgs
            Syncfusion.Windows.Forms.Grid.GridCellCancelEventArgs
               Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs

AssemblyVersion

Syncfusion.Grid.Windows: 17.2460.0.34

See Also