How do I conditionally set the format of a single cell in GridGroupingControl?
(Views :1895)

The formatting of the cell can be handled in the QueryCellStyleInfo event. The DataRowView class can be used to get the data from the record, which in turn can be used for checking any conditions.

C#
private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if( e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell
|| e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
{
// Checking for the column name and if the cellvalue is greater than 5.
if(e.TableCellIdentity.Column.MappingName == "Col1" && (int)e.Style.CellValue > 5)
{
e.Style.BackColor=Color.LightBlue;
e.Style.Format="##.00";
}
}
}
VB
Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As
Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs) Handles gridGroupingControl1.QueryCellStyleInfo
If e.TableCellIdentity.TableCellType = GridTableCellType.RecordFieldCell OrElse e.TableCellIdentity.TableCellType =
GridTableCellType.AlternateRecordFieldCell Then
' Checking for the column name and if the cellvalue is greater than 5.
If e.TableCellIdentity.Column.MappingName = "Col1" AndAlso CInt(e.Style.CellValue) > 5 Then
e.Style.BackColor = Color.LightBlue
e.Style.Format = "##.00"
End If
End If
End Sub

Sample:

http://websamples.syncfusion.com/samples/kb/grid.windows/GGCCondtionalFormatSingleCell/main.htm

::adCenter::