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

Column color

Hi, I want to set the specific colors to the whole columns. Like among the 50 columns i want to set color depending upon the header value. Which method is used for this and where to call this method Regards Pratiksha

1 Reply

AD Administrator Syncfusion Team April 20, 2005 09:56 AM UTC

What kind of grid are you using? In a GridControl, you can set the BackColor of a column by setting grid.ColStyles[colIndex].BackColor. So, after the grid has been populated with its header text (maybe in Form.Load), you could loop through the columns from 1 to grid.ColIndex, testing the header text for the column and setting the grid.ColStyles[colIndex].BackColor accordingly. In a GridDataBoundGrid, the BackColor of a column is set using the GridBoundColumn.StyleInfo.backColor for that column. So, again after the grid has been populated you could loop through the collection of GridBoundColumn objects, testing GridBoundColumn.Headertext and setting GridBoundColumn.StyleInfo.BackColor accordingly. If you have explicitly added GridBoundColumns to your grid, then you would loop through this collection, grid.GridBoundColumns. If you have not added GridBoundColumns, then you would loop through this collection, grid.Binder.InternalColumns.

Loader.
Up arrow icon