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

HighlightCurrentColumnHeader setting the color

I have multi-line column headers and the HighlightCurrentColumnHeader works great for determining the current cell''s column, however the header style''s back color is tan and the text color is White and it''s very hard to read. I''ve tried handling the grid model''s PrepareViewStyleInfo method, but when I try to extract a change in the color of the text or set the text to a differnt color it has no effect; it''s as if the highlight color (white) is being set after this event. How do I choose the highlight color for the column headers?

4 Replies

FR Fred April 3, 2006 03:07 PM UTC

FYI... this is with GDBG 4.1


AD Administrator Syncfusion Team April 4, 2006 05:29 AM UTC

Hi Fred, To customize the look of the highlighted header you should handle the PrepareViewStyleInfo event and check IsMarkedHeader and set Cancel to True. Here is the code snippet private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e) { if(this.gridDataBoundGrid1.IsMarkedHeader(e.RowIndex,e.ColIndex)) { e.Style.BackColor = Color.YellowGreen; e.Style.TextColor = Color.Brown; e.Style.Font.Bold = true; e.Cancel = true; } } Best regards, Madhan


FR Fred April 4, 2006 03:55 PM UTC

Thanks! That''s exactly what I needed. Can I ask why you needed to set e.Cancel = true to get that to work? Seems kind of backwards to me; I''m not following that logic...


AD Administrator Syncfusion Team April 5, 2006 08:50 AM UTC

Hi Fred, If you step into the source code and trace the PrepareViewStyleInfo event [ GridDataBoundGrid.cs ]. You will notice the default Backcolor and TextColor is set if the e.Cancel property is false. To get more details, please derive a grid from GridDataBoundGrid and apply the following code snippet. protected override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e) { base.OnPrepareViewStyleInfo(e); if (!e.Cancel && !CurrentCell.StaticDrawing && !PrintingMode && IsMarkedHeader(e.RowIndex, e.ColIndex)) { e.Style.BackColor = Color.YellowGreen; e.Style.TextColor = Color.White; } } Thanks for the patience. Best regards, Madhan

Loader.
Live Chat Icon For mobile
Up arrow icon