Members  Example 

Syncfusion.Windows.Forms.Grid Namespace : GridQueryCellInfoEventArgs Class

GridQueryCellInfoEventArgs Class

Provides data about the QueryCellInfo event which can be marked as handled.
Object Model
GridQueryCellInfoEventArgs ClassGridStyleInfo Class
Public NotInheritable Class GridQueryCellInfoEventArgs 
   Inherits GridCellHandledEventArgs
Dim instance As GridQueryCellInfoEventArgs
public sealed class GridQueryCellInfoEventArgs : GridCellHandledEventArgs 
GridQueryCellInfoEventArgs is a custom event argument class used by the QueryCellInfo event to query style information concerning a specified cell.

This event allows you to customize cell contents at run-time on demand, just before the cell is drawn or programmatically accessed through GridModel.Item, GridModel.ColStyles, GridModel.RowStyles, or GridModel.TableStyle.

If you made changes to Style, you should also set Syncfusion.ComponentModel.SyncfusionHandledEventArgs.Handled to True. The grid will check this flag to see whether the style has been initialized. If the event has been marked as handled, the grid will not access cell information from its own data store Data. In the default case when the event is not marked as handled, the grid will locate cell information by calling GridData.Item.

In your handler for this event, normally you would set the CellValue for the GridStyleInfo object passed in with the event arguments. But you can also set other members of this GridStyleInfo object. For example, you could set BackColor to change the cell background. And, all this is done on a demand basis. There would be no BackColor value stored in any grid storage.

The GridQueryCellInfoEventArgs members, e.ColIndex and e.RowIndex, specify column and row of the requested style. The e.Style member holds the GridStyleInfo object whose value this event should set provided it is a cell that you want to populate. It is possible that e.ColIndex and / or e.RowIndex may have the value of -1. A -1 indicates that a row style or column style is being requested. So, e.ColIndex = -1 and and e.RowIndex = 4 indicates the rowstyle for row 4 is being requested (GridControl.RowStyles[4]). Similarly, a positive column value with the row value = -1 would be a request for that particular columnstyle. If both values are -1, then the TableStyle property is being requested.

Header rows and columns in an Essential Grid are treated the same as other rows and columns with respect to QueryCellInfo. If you have a single header row, then anytime e.ColIndex is 0, a row header is being requested. Similarly, if you have a single column header row, e.RowIndex = 0 is a request for the column header.

Style information provided with QueryCellInfo is cached. This ensures this event is not hit everytime cell information is needed (e.g. when the user moves the mouse) and possibly forces a lookup in an external datasource which could be extensive depending on your implementation. If underlying data changes and you want to force a new call to QueryCellInfo, you should call GridModel.ResetVolatileData for the GridModel of a grid.

You should not provide information in QueryCellInfo that depends on current view context, like changing the appearance of the cells that are on the current edited row. Use the GridControlBase.PrepareViewStyleInfo event to change the style of such cells about to be drawn. This event is fired from the cell renderer, and only reflects transient information which is not cached in the grid.

QueryCellInfo is fired from GridModel, and should be used mainly to provide non-transient information for a style such as the value from an external data source in a virtual grid. GridControlBase.PrepareViewStyleInfo is fired for every grid view and unique style settings for each view of the same model.

See also the Virtual grid source code for example.

private void GridQueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
        if(e.ColIndex > 0 && e.RowIndex > 0)
            e.Style.CellValue = this.intArray[e.RowIndex - 1, e.ColIndex - 1];
            e.Handled = true;
Private Sub GridQueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
        If ((e.ColIndex > 0) AndAlso (e.RowIndex > 0)) Then
            e.Style.CellValue = Me.intArray(e.RowIndex - 1, e.ColIndex - 1)
            e.Handled = True
        End If
End Sub
Inheritance Hierarchy



Syncfusion.Grid.Windows: 17.1460.0.47

See Also