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

HighlightCurrentColumnHeader setting the color

Thread ID:





42617 Apr 3,2006 03:05 PM UTC Apr 5,2006 08:50 AM UTC WinForms 4
Tags: GridControl
Asked On April 3, 2006 03:05 PM UTC

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?

Replied On April 3, 2006 03:07 PM UTC

FYI... this is with GDBG 4.1

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

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

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


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