The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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?
ADAdministrator 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
FRFredApril 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...
ADAdministrator 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