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

Changing Column Header Color/Style

How does one get at the column (and row) headers to change styles? I want to change the background color of the header (at the top of the grid). I have tried several things with no effect. I started with the BaseStyle designer dialog and assume that the pre-created header base styles were used by the header. These had no effect. Then I tried to get it at the header through specific cells, model and internal columns, but I cannot seem to find anything that affects the style for the header row. The most I can do is set the number of header rows, text, add and image and turn the header on or off. Is there a way to access the header''s style?

5 Replies

AD Administrator Syncfusion Team March 6, 2006 10:06 AM UTC

Hi Michael, The headers styleInfo can be accessed by the grid.BaseStylesMap property. Below is a code snippet. It can also be accessed in the design mode through the Property Window under the Grid Contents, BaseStylesMap Collection. gridControl1.BaseStylesMap["Header"].StyleInfo.BackColor = Color.Tomato; gridControl1.BaseStylesMap["Row Header"].StyleInfo.BackColor = Color.SteelBlue; gridControl1.BaseStylesMap["Column Header"].StyleInfo.BackColor = Color.Tan; Regards, Calvin.


MI Michael March 9, 2006 04:32 AM UTC

This seems right, but it still does not change the column header''s color. I add a data bound grid. I change the background color to white and make the grid read only through properties in design mode. At run time, I bind the grid to a data source. I change the text of the header columns and hide a few columns. Then, I try to change the color as you suggested and nothing happens. The only other odd thing is the form is inherited, but the grid is not in the base form. It is directly on the new form that inherited the base form.


AD Administrator Syncfusion Team March 9, 2006 12:38 PM UTC

Hi Michael, The this.gridDataBoundGrid1.BaseStylesMap["Column Header"].StyleInfo.BackColor property works fine. The GridBoundColumn.HeaderText property of a column must be used to change the column header text. If you did not add GridBoundColumns, then GridDataBoundGrid.Binder.InternalColumns HeaderText property must be used. Please refer the attached sample. Best Regards, Calvin.

41556.zip


MI Michael March 16, 2006 09:45 PM UTC

Calvin, Thank you for the example. Your code appears to be the same code I use, but again nothing happened. I can hide the columns and change the header text, but color changes have no effect. However… I did finally fix the problem by simply deleting the grid and adding a new one. This fixed it. As near as I can figure, some property became screwed up in all of my trying to get the color to change. I have now gotten into the habit of deleting and re-adding grids when I am certain my code is working or properly formed but the grid is not behaving as expecting. There are so many layers of properties it is too difficult to track which property (and where) changes or affects what. I suggest that SyncFusion produces a 24 x 36” poster that maps the grid properties and objects. It would shorten the learning curve for those items that do not have a cut and paste example.


AD Administrator Syncfusion Team March 17, 2006 03:20 AM UTC

Hi Michael, We are glad that you got it solved and also thankful for your suggestion. Surely we will look in to it. Best Regards, Calvin.

Loader.
Live Chat Icon For mobile
Up arrow icon