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.

Color change for the background per row

Thread ID:

Created:

Updated:

Platform:

Replies:

121039 Nov 5,2015 02:34 AM Nov 9,2015 07:48 AM Windows Forms 1
loading
Tags: GridGroupingControl
Pierre Smith
Asked On November 5, 2015 02:34 AM

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


Adhikesevan Kothandaraman [Syncfusion]
Replied On November 9, 2015 07:48 AM

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

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.

;