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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Changing Column Header Color/Style

Thread ID:





41556 Mar 6,2006 04:34 AM UTC Mar 17,2006 03:20 AM UTC WinForms 5
Tags: GridControl
Asked On March 6, 2006 04:34 AM UTC

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?

Administrator [Syncfusion]
Replied On 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.

Replied On 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.

Administrator [Syncfusion]
Replied On 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.


Replied On 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.

Administrator [Syncfusion]
Replied On 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.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon