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.