gridgroupin control cell conditional formating from value from another column
ie if col a row 5 value >5 then col b row 5 cell backcolor=5
i have somehow managed to do it using QueryCellStyleInfo but the grid crashes after using the field chooser to change the displayed columns
any help woud be greatly appreciated.
Hi Panos,
Thank you for using Syncfusion products.
Instead of using QueryCellInfo event for conditional formatting, you can use the GridConditionalFormatDescriptor. Please refer to the below code example and sample for reference.
Code Example :
Syncfusion.Windows.Forms.Grid.Grouping.GridConditionalFormatDescriptor gridConditionalFormatDescriptor1 = newSyncfusion.Windows.Forms.Grid.Grouping.GridConditionalFormatDescriptor();
gridConditionalFormatDescriptor1.Appearance.AnyRecordFieldCell.Interior = newSyncfusion.Drawing.BrushInfo(System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(191)))), ((int)(((byte)(52))))));
gridConditionalFormatDescriptor1.Appearance.AnyRecordFieldCell.TextColor = System.Drawing.Color.White;
gridConditionalFormatDescriptor1.Expression = "[CustomerID] LIKE \'A*\'";
gridConditionalFormatDescriptor1.Name = "ConditionalFormat 1";
Sample :
https://www.syncfusion.com/downloads/support/forum/121387/ze/CS-2110415607
Note :
If the issue is still not resolved, please replicate your issue in this sample and send it to us, so that it would help us provide a prompt solution.
Thanks,
AL.Solai.
Thank you for your update.
We have changed the sample with conditional formatting for the single cell value using the QueryCellInfo event and also tried using the field chooser. The sample is working fine at our end. Could you please replicate the issue scenario in this sample and update us?
Code Example :
void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if(e.TableCellIdentity.ColIndex>0 && e.TableCellIdentity.RowIndex>0 && e.Style.Text == "Sales Representative")
{
e.Style.BackColor = Color.GreenYellow;
}
}
Modified Sample :
https://www.syncfusion.com/downloads/support/forum/121387/ze/CS_(2)161555433
Note : QueryCellInfo event would be triggered frequently. So, using this event for a single condition will not be an appropriate solution. It may affect the performance when a large data is involved.
Thanks,
AL.Solai.
- 3 Replies
- 2 Participants
-
PV panos veinoglou
- Dec 8, 2015 09:33 PM UTC
- Dec 10, 2015 10:44 AM UTC