We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Grid conditional formatting

I was trying to implement conditional formatting in the Grid control by using the GridQueryCellInfoEventHandler.  I want to change the BackColor based on the value of the cell.  The Style property of GridQueryCellInfoEventArgs has CellValue and Text properties but they are always blank.  Any hints on how this can be implemented?

Thanks
Jon


1 Reply

AR Arulpriya Ramalingam Syncfusion Team May 16, 2017 09:58 AM UTC

Hi Jon, 

Thanks for your interest in Syncfusion products. 

In order to achieve the ConditionalFormatting based on cell value, the PrepareViewStyleInfo event can be used. In that event, e.Style.BackColor property can be used to set the back color. Please make use of below code and sample, 

Code snippet 
 
//Event Triggering 
gridControl1.PrepareViewStyleInfo += GridControl1_PrepareViewStyleInfo; 
 
//Event Customization 
private void GridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e) 
{ 
    if (e.Style.CellValue.ToString() == "AAAA") 
    { 
        e.Style.BackColor = Color.Yellow; 
    } 
} 
 
 
 
Regards, 
Arulpriya 


Loader.
Live Chat Icon For mobile
Up arrow icon