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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid conditional formatting

Thread ID:

Created:

Updated:

Platform:

Replies:

130492 May 16,2017 02:00 AM UTC May 16,2017 09:58 AM UTC WinForms 1
loading
Tags: GridControl
Jon Shuler
Asked On May 16, 2017 02:00 AM UTC

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


Arulpriya Ramalingam [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;