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.
Unfortunately, activation email could not send to your email. Please try again.

Grid conditional formatting

Thread ID:

Created:

Updated:

Platform:

Replies:

130492 May 15,2017 10:00 PM May 16,2017 05:58 AM Windows Forms 1
loading
Tags: GridControl
Jon Shuler
Asked On May 15, 2017 10:00 PM

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 05:58 AM

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.

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.

;