GridControl Theme - Change header cell color and print

Hello,
I'm using a GridControl with Office2016Black theme and I have 2 questions:
- Is it possible to change one header cell backcolor or textcolor mannualy? I've seen thread 3947 but this changes all the header cells.
- When printing (GridPrintDocumentAdv) this grid with theme the header not respect the header theme colors. Is this normal?
- When a cell is .CellType = "DateTimePicker" both backcolor and textcolor are white when editing the cell. Is this normal? How can I change one color?
Thanks

6 Replies

AR Arulpriya Ramalingam Syncfusion Team April 1, 2020 04:52 PM UTC

Hi Dinis, 
 
Thank you for your interest in Syncfusion products. 
 
- Is it possible to change one header cell backcolor or textcolor mannualy? I've seen thread 3947 but this changes all the header cells. 
GridControl Themes does not provide support to update the individual header cell background color since, the backcolor is updated based on the HeaderStyle. If you need to change the backcolor for individual cells, we would suggest that you to update the BackColor using QueryCellInfo event instead of themes. Please refer to the below UG link. 
 
- When printing (GridPrintDocumentAdv) this grid with theme the header not respect the header theme colors. Is this normal? 
In order to update the header background color while printing the grid, the QueryCellInfo event can be used. Please make use of the below code and UG link. 
 
Example code 
 
private void GridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) 
{ 
    if (this.gridControl1.PrintingMode) 
    { 
        //Column headers or Row headers 
        if (e.RowIndex == 0 || e.ColIndex == 0) 
        { 
            e.Style.BackColor = Color.Black; 
            e.Style.Borders.All = new GridBorder(GridBorderStyle.Solid, Color.Gray); 
        } 
    } 
} 
 
 
Please get back to us, if you have any other queries. 
 
Regards, 
Arulpriya 



DF Dinis Ferreira April 1, 2020 06:34 PM UTC

Hello Arulpriya Ramalingam,
Thanks for the help.

Your sugestions didn't work:
1- I can only change backgroud header cell if I ThemeEnable=False
2- I can't use QueryCellInfo event provably beacause I use a temp GridControl. The event doesn't start. My code is:
     System.IO.MemoryStream strm = new System.IO.MemoryStream();
     MyGrid.Model.SaveBinary(strm);
     strm.Position = 0;
     gridTmp = new GridControl(GridModel.LoadBinary(strm));
     gridTmp.QueryCellInfo += new GridQueryCellInfoEventHandler(gridTmp_QueryCellInfo);

I've add a new question about Office2016Black Theme:
- When a cell is .CellType = "DateTimePicker" both backcolor and textcolor are white when editing the cell. Is this normal? How can I change one color?

Thanks


AR Arulpriya Ramalingam Syncfusion Team April 2, 2020 06:11 PM UTC

Hi Dinis, 
 
Thank you for the update. 
 
1- I can only change backgroud header cell if I ThemeEnable=False 
As per the GridControl current behavior, the background and foreground will be updated based on the theme name when the ThemesEnabled is true. We would suggest that you to disable the same to avail your own customized  theme colos. 
2- I can't use QueryCellInfo event provably beacause I use a temp GridControl. The event doesn't start. My code is: 
     System.IO.MemoryStream strm = new System.IO.MemoryStream(); 
     MyGrid.Model.SaveBinary(strm); 
     strm.Position = 0; 
     gridTmp = new GridControl(GridModel.LoadBinary(strm)); 
     gridTmp.QueryCellInfo += new GridQueryCellInfoEventHandler(gridTmp_QueryCellInfo); 
We could understand the scenario and need some time to validate further on this to confirm whether is it a defect from our end. So we will update you the proper details on 06th April 2020. We appreciate your patience till then. 
I've add a new question about Office2016Black Theme: 
- When a cell is .CellType = "DateTimePicker" both backcolor and textcolor are white when editing the cell. Is this normal? How can I change one color? 
 
Regards, 
Arulpriya 



AR Arulpriya Ramalingam Syncfusion Team April 9, 2020 03:34 PM UTC

Hi Dinis, 
 
Thanks for your patience. 
 
We have validated the reported use case and as per the GridControls current behavior, the HeaderStyle will be printed based on the ThemeStyle of the GridControl for the advanced themes like Metro, Office2016 and Office2019 themes. And you have used the Office2016Black theme for which the header backcolor is Black and forecolor is white. So that the reported scenario and this can only be avoided by QueryCellInfo event whereas, you have used the GridControl from Stream. So, we regret to let you know that the GridControl does not have the support to achieve your requirement. 
 
Please get back to us, if you need any further assistance. 
 
Regards, 
Arulpriya 



DF Dinis Ferreira April 10, 2020 12:27 PM UTC

Hello,
Thanks for the update.
What about questions 1 and 3?
Thank you


AR Arulpriya Ramalingam Syncfusion Team April 13, 2020 06:01 PM UTC

Hi Dinis, 
 
Thank you for the update. 
 
As we updated in our previous update, the HeaderColor is updated based on the HeaderStyleInfo when printing and the DateTimePicker is used internally in the DateTimePicker cell renderer. So, we regret to let you know that the background for DateTimePicker control could not be changed in sample level. Whereas, you can create a CustomCellModel and CellRenderer with customized background color for DateTimePickerControl. Please make use of the below UG to know more about the custom cell models. 
 
 
Please get back to us, if you have any other queries. 
 
Regards, 
Arulpriya 


Loader.
Up arrow icon