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

AlternatingRowsDefaultCellStyle

Hi, everyone

I'm looking something similar to AlternatingRowsDefaultCellStyle. I don't want to be responsible for each row's backcolor (even after I sort the grid). I want everything will be automated.

Thanks in advance, and have a good day :)
Allon

7 Replies

JJ Jisha Joy Syncfusion Team October 21, 2009 11:32 AM UTC

Hi Allon,

Thank you for posting query to us. If your intesion is to apply styles to the alternating rows in GridGroupingControl, this can be achieved by using the AlternateRecordFieldCell property of grid. See the code:
this.gridGroupingControl1.TableDescriptor.Appearance.AlternateRecordFieldCell.BackColor = Color.AliceBlue;
this.gridGroupingControl1.TableDescriptor.Appearance.AlternateRecordFieldCell.TextColor = Color.Wheat;

Please let me know if this helps.

Regards,
Jisha


AL Allon October 22, 2009 07:46 AM UTC

Hi, Jisha

Thanks for replying me, but I work with Grid control, and TableDescriptor is not one of it's properties.

Thanks in advance :)
Allon


AL Allon October 22, 2009 09:02 AM UTC

Hello, again

An answer relates to PrepareViewStyleInfo won't be helpful, because There are a lot of problems changing the bgColor after using it.

Regards,
Allon


JJ Jisha Joy Syncfusion Team October 22, 2009 10:33 AM UTC

Hi Allon,

In GridControl you can set row styles to the RowStyles property. See the code for setting alternate row setting for GridControl.


//Alternate row styles
for(int i=1;i<=this.gridControl1.RowCount; i++)
{
if(i%2==0)
this.gridControl1.RowStyles[i].BackColor = Color.Pink;
else
this.gridControl1.RowStyles[i].BackColor = Color.LightBlue;
}


Regards,
Jisha


AL Allon October 22, 2009 12:04 PM UTC

Hi Jisha,

This is exactly what I did, but the results are poor when I sort rows in the grid control according to some beautiful solution which Lingaraj S. has sent me in 19/10/2009 (http://www.syncfusion.com/support/forums/grid-windows/90745/grid-control-sorting). If I use that sorting method, and use what you have just suggested me, row's background color remain and it becomes orderless (unless after sorting, I use the loop you have sent me again). I've got no problem to use that loop, but after sorting the grid, there would be a lot of mess, which I want to avoid. It would be great if you could add the ability to take control on alternating background color to the app Lingaraj S. has sent me.

Regards,
Allon


AL Allon October 22, 2009 01:03 PM UTC

Hi Jisha,

I think I found something that works quit fast, and apparently everything will be just fine, if I just write your loop before grdNew.Refresh() in SortCol() subroutine.

Have a nice day :)
Allon


JJ Jisha Joy Syncfusion Team October 23, 2009 06:19 AM UTC

Hi Allon,

Thank you for your update.

Regards,
Jisha

Loader.
Live Chat Icon For mobile
Up arrow icon