Class GridQueryCellInfoEventArgs
Provides data about the QueryCellInfo event which can be marked as handled.
Inheritance
Inherited Members
Namespace: Syncfusion.Windows.Forms.Grid
Assembly: Syncfusion.Grid.Windows.dll
Syntax
public sealed class GridQueryCellInfoEventArgs : GridCellHandledEventArgs
Remarks
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 Item[Int32, Int32], ColStyles, RowStyles, or TableStyle.
If you made changes to Style, you should also set 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 Item[Int32, Int32].
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 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 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. 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.
Examples
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
Constructors
GridQueryCellInfoEventArgs(Int32, Int32, GridStyleInfo)
Initializes the new instances of the GridQueryCellInfoEventArgs class.
Declaration
public GridQueryCellInfoEventArgs(int rowIndex, int colIndex, GridStyleInfo style)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The row index. |
System.Int32 | colIndex | The column index. |
GridStyleInfo | style | The style information for the cell. |
Properties
Style
Gets the style information for the cell.
Declaration
[TraceProperty(true)]
public GridStyleInfo Style { get; }
Property Value
Type |
---|
GridStyleInfo |