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

Color change for the background per row

Hi

I need to be able to set the background color for a entire row
I want the user to be able to click on a specific line and then press a button to change the color to something else
i also want to be able to iterate throught the data and check things like duplicate data and make those lines a different color

Can someone help me with that please
thank you


1 Reply

AK Adhikesevan Kothandaraman Syncfusion Team November 9, 2015 12:48 PM UTC

Hi Pierre,

Thanks for contacting Syncfusion Support.

If you want to change the back color of the record while clicking the button, it can be done by using the following customization,

Code Snippet:

//To set the back colors for the records

this.gridGroupingControl1.QueryCellStyleInfo += gridGroupingControl1_QueryCellStyleInfo;

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)

 {

     if(e.TableCellIdentity.RowIndex == row && highlight)

     {               

         e.Style.BackColor = Color.Green;

     }

     if(rowCollection.Contains(e.TableCellIdentity.RowIndex))

     {

         //Set the color for Duplicate values

         e.Style.BackColor = Color.LightGreen;

     }

 }


 int row, col;

 int[] rowCollection = new int[10];

 bool highlight = false;

 private void button1_Click(object sender, EventArgs e)

 {

     highlight = true;

     row = this.gridGroupingControl1.TableControl.CurrentCell.RowIndex;


     //For validating the data

     string data = this.gridGroupingControl1.Table.CurrentRecord.GetValue("No").ToString();

    

     foreach(Record rec in this.gridGroupingControl1.Table.Records)

     {

         int i=0;

         if(rec.GetValue("No").ToString() == data && rec.GetRowIndex() != row)

         {

             rowCollection[i] = rec.GetRowIndex();

             i++;

         }

     }

     this.gridGroupingControl1.Refresh();
 }


Sample: http://www.syncfusion.com/downloads/support/forum/121039/ze/SelectionColor-GG-294462146

Regards,
Adhi

Loader.
Live Chat Icon For mobile
Up arrow icon