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

Highlight a row based on record value from hidden column


I have a gridgrouping control databound to a datatable in dataset. I have a hidden column (removed it from visible columns). I would like to highlight the row in the grid based on value in the hidden column. Please let me know which event to handle for this. The row should be highlighted using backcolor irrespective of whether user clicked on it or not. Please clarify this.


1 Reply

AR Amal Raj U Syncfusion Team November 8, 2016 01:48 PM UTC

Hi Devi, 

Thanks for using Syncfusion products. 

The reported scenario of highlighting the row based on hidden columns cell value can be done using Conditional Formatting. By default when condition formatting are enabled,  the SelectionBackColor  will override the highlighted record’s BackColor, this can be resolved by using TableControlDrawCellDisplayText event. Please make use of the below code, 
Code Snippet 
//Conditional Formatting. 
GridConditionalFormatDescriptor descriptor1 = new GridConditionalFormatDescriptor(); 
descriptor1.Appearance.AnyRecordFieldCell.BackColor = Color.Green; 
descriptor1.Expression = "[ContactTitle] = \'Sales Manager\'"
//Event Subscription. 
this.gridGroupingControl1.TableControlDrawCellDisplayText += new GridTableControlDrawCellDisplayTextEventHandler(gridGroupingControl1_TableControlDrawCellDisplayText); 
void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e) 
    GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex); 
    if (style == null || style.TableCellIdentity == null || style.TableCellIdentity.Column == null  
        || style.TableCellIdentity.DisplayElement.GetRecord() == null
    if (style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell  
        || style.TableCellIdentity.TableCellType == GridTableCellType.AnyRecordFieldCell  
        || style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell) 
        Record record = style.TableCellIdentity.DisplayElement.GetRecord(); 
        if (descriptor1.CompareRecord(record) && record.IsCurrent) 
            Rectangle rectangle = e.Inner.ClipBounds; 
            rectangle.Height += 4; 
            rectangle.Width += 4; 
            e.Inner.Graphics.FillRectangle(new SolidBrush(Color.Green), rectangle); 
Sample Link 
Amal Raj U. 

Live Chat Icon For mobile
Up arrow icon