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

GridGroupingControl - Selected Row Color

Hi,

We are using V 4.2.0.37.

Our GGC control has some columns being displayed in different colors. We are setting these colors conditionally in QueryCellStyleInfo event.

But when we select the row, as row selection color is blue, blue color is overriding the column colors. What is the fix for this?

While grid is applying blue color, can I prevent it for certain cells?

Rgds
Rajani kanth

3 Replies

AD Administrator Syncfusion Team October 19, 2006 04:35 PM UTC

Hi Rajani,

You can change the row selection backcolor to any color you wish using the below piece of code.
//
this.gridGroupingControl1.TableOptions.SelectionBackColor = Color.Green;
//

Thanks,
Rajagopal


ND Nagaraju Dhulipalla September 17, 2018 04:09 PM UTC

this.gridGroupingControl1.TableOptions.SelectionBackColor = Color.Green;

using the above code, did not solve the problem mentioned below

Our GGC control has some columns being displayed in different colors. We are setting these colors conditionally in QueryCellStyleInfo event.

But when we select the row, as row selection color is blue, blue color is overriding the column colors. What is the fix for this?

While grid is applying blue color, can I prevent it for certain cells?


MG Mohanraj Gunasekaran Syncfusion Team September 18, 2018 12:37 PM UTC

Hi Nagaraju, 
 
Thanks for using Syncfusion product. 
 
To avoid the selection back color override your conditional styling, you could disable the SupportsPrepareViewStyleInfo and use the QueryCellStyleInfo event to set the selection BackColor for other columns. Please refer the following code example and the sample, 
 
Code example 
this.gridGroupingControl1.TableControl.SupportsPrepareViewStyleInfo = false; 
private void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) 
{ 
    if (e.TableCellIdentity == null || e.TableCellIdentity.Column == null) 
        return; 
    GridCurrentCell currentCell = this.gridGroupingControl1.TableControl.CurrentCell; 
    if (e.TableCellIdentity.DisplayElement.Kind == Syncfusion.Grouping.DisplayElementKind.Record) 
    { 
        if (e.TableCellIdentity.Column.Name == "Name" && e.TableCellIdentity.RowIndex % 3 == 0) 
        { 
            e.Style.BackColor = Color.Yellow; 
            e.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Yellow); 
        } 
        else if (e.TableCellIdentity.DisplayElement.GetRecord().IsSelected() 
            && currentCell.ColIndex != e.TableCellIdentity.ColIndex) 
        { 
            //To set the backcolor for selected records 
            e.Style.BackColor = this.gridGroupingControl1.TableOptions.SelectionBackColor; 
            e.Style.TextColor = Color.White; 
        } 
    } 
} 
 
 
Regards, 
Mohanraj G 


Loader.
Live Chat Icon For mobile
Up arrow icon