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

Cells Colors

I have created a GridDataBound and it's data source i chose a DataTable . now , each time I add something to the DataTable it also appears on the GridDataBound . my problem is like this , I wanna change the background of one or more rows , or if that is not possible I wanna change cells colors . I tried changing the color of the cells like this : gridDataBound1 [ 1 , 1 ].BackColor = Color.Aqua but it won't change it ... why is that ? and how can I change a whole row or at least one cell . thanks for the help .

4 Replies

AD Administrator Syncfusion Team November 5, 2003 10:06 AM

There are a couple of KB articles that discuss how to do this. http://www.syncfusion.com/KB/Grid/Grid_c35c.asp#q560q http://www.syncfusion.com/KB/Grid/Grid_c35c.asp#q561q


AL Alex November 5, 2003 10:29 AM

but how do I call this function , it is an event and not a function . i want a function that recevies a primary key in the DataTable and changes the row color in the GridDataBound . please help me ...


AD Administrator Syncfusion Team November 5, 2003 11:14 AM

You cannot call a function and change the color of a row in a GridDataBoundGrid. The reason is that there no properties stored on a row basis in a GridDataBoundGrid. Instead, you must listened for the PrepareViewStyleInfo event. There, if e.RowIndex and e.ColIndex point to a cell that you want to color, you should set e.Style.BackColor to the desired color. (This way, there is never any color saved for a particular cell or row. It is always provided on demand through this event). You can use grid.Binder.NameToColIndex to find out the column index for your key column. Attached is a little sample that colors any row whose 'primary key' value is divisible by 4.


AL Alex November 5, 2003 02:13 PM

well , ok thanks I will try it tommorow at work and see if it works .

Loader.
Live Chat Icon For mobile
Up arrow icon