Font color for Column header and row header

Posted by: david.sheppard on 20 November 2023, 1:31 am EST

  • Posted 20 November 2023, 1:31 am EST - Updated 20 November 2023, 1:36 am EST

    The default shows the row headers and column headers as grey (see attached image). Users are complaining that they are not legible on some screens.

    How can I set the text in the column headers to black?

  • Posted 21 November 2023, 5:23 pm EST

    Hi,

    Could you please confirm which version of Spread.Net you are working with?

    We can see Black Foreground for ColumnHeaders and RowHeaders in Spread 16 and 15.

    However, if you want to customize ColumnHeader and RowHeader text. Then you can implement PaintCell method of Renderer(see code snippet)

     public void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
     {
         var font = 14 * zoomFactor;
         float stringWidth =((float)(g.MeasureString("ID", new System.Drawing.Font("Calibri", font))).Width)/2f;
         g.DrawString(value.ToString(), new System.Drawing.Font("Calibri",font), Brushes.Red, new PointF(r.X +(((float)r.Width / 2f) - stringWidth)-5, r.Y-3));
     }

    Please refer the attached sample for the same: SpreadHeaderFormat.zip

    Best Regards,

    Nitin

  • Posted 22 November 2023, 12:09 am EST

    I am using Spread.Net version 16.0.20221.3

    I have tried setting the forecolor of the column headers in two ways and neither method worked:

    fpspread1.activesheet.columnheader.rows(0).forecolor=color.black;

    fpspread1.activesheet.columnheader.columns(0).forecolor=color.black;

    It seems like the methods that I tried should work, but they are not implemented. I also tried the code above and set the color to blue, but it made no change to the header text color.

    I would like to avoid using a customized paintcell method like the one in the example.

  • Posted 22 November 2023, 5:47 pm EST

    Hi,

    If you don’t want to customize the Header and only want to change the ForeColor/BackColor on Headers.

    Then you need to disable the default Paint on Headers first and then you can set ForeColor/BackColor (see code snippet)

    fpSpread1.PaintSelectionHeader = False 'Disable default Paint on Headers
    fpSpread1.ActiveSheet.ColumnHeader.Rows(0).ForeColor = Color.Black
    fpSpread1.ActiveSheet.ColumnHeader.Rows(0).BackColor = Color.Yellow
    fpSpread1.ActiveSheet.RowHeader.Columns(0).ForeColor = Color.Black
    fpSpread1.ActiveSheet.RowHeader.Columns(0).BackColor = Color.Yellow

    Please refer the attached sample for the same: SpreadHeaderFormat_Mod.zip

    Best Regards,

    Nitin

  • Posted 22 November 2023, 11:51 pm EST - Updated 22 November 2023, 11:56 pm EST

    Nitin, thank you for working with me on this.

    The PaintSelectionHeader = False command did not make a difference. The text remained grey. The background color would changed to yellow when PaintSelectionHeader was true or false.

  • Posted 27 November 2023, 8:39 pm EST

    Hi David,

    Apologize for the inconvenience caused to you.

    We are able to update ForeColor of Header Text(refer the provided sample in previous post).

    Could you please provide a stripped-down sample replicating your Spread Header Behavior? So, that we can provide a solution for it.

    Regards,

    Nitin

  • Posted 28 November 2023, 9:21 am EST - Updated 28 November 2023, 9:27 am EST

    I stripped all of the code out of a solution and just added back a couple of lines in the form load.

    TestSpread.zip

  • Posted 28 November 2023, 11:37 pm EST

    Hi David,

    We have replicated this behavior at our end. SheetView is created at design time and ForeColor doesn’t affect ColumnHeader on Load.

    In order to achieve your requirement, you can customize it at design time.

    Please refer the attached modified sample for the same: TestSpread_Mod.zip

    Regards,

    Nitin

  • Posted 29 November 2023, 12:08 am EST

    The propose solution does make the header text black, but it removes the ability to show locked cells to be shown with a lockbackcolor.

    Having locked cells shown with a different back color is required so that users know which values they can edit.

    The proposed solution also requires the removal of the sheet.protect statement. If I use the sheet.protect statement locked cells are shown with a different back color, but the headers are not black. When I remove the sheet.protect statement the header text is black, but locked cells do not have a different back color

  • Posted 29 November 2023, 11:42 pm EST

    Hi David,

    We have escalated this issue to the development team. We will get back to you once we have any updates from them.[Internal Tracking Id - SPNET-35573]

    Regards,

    Nitin

  • Posted 29 November 2023, 11:48 pm EST

    Thank you.

  • Posted 19 January 2024, 2:09 am EST

    I see that version 17 has been published. Has this issue been corrected in version 17?

    Thank you.

  • Posted 21 January 2024, 4:29 pm EST

    Hi,

    Apologize for the delay.

    This issue is under investigation. We have asked for an update on this issue. Will let you know once we have any update from them.

    Best Regards,

    Nitin

  • Posted 10 April 2024, 5:26 am EST

    I found a solution. It is the ActiveSheet.Protect function that makes the text in the column and row headers grey.

    The way to make the text return to normal is to set to false the locked property for the row header and column header.

    FPSpread1.ActiveSheet.RowHeader.Columns(0).Locked = False

    FPSpread1.ActiveSheet.ColumnHeader.Rows(0).Locked = False

  • Posted 10 April 2024, 3:04 pm EST

    Hi David,

    Yes, you can unlocked the headers in this case. If the header cell is locked, the render will be paint the foreColor as disable color (SystemColors.ControlLightLight). This is by design.

    You can set the header’s locked is false to paint the foreColor the code like below:

    FPSpread1.Sheets(0).ColumnHeader.Rows(0).ForeColor = Color.Black
    FPSpread1.Sheets(0).ColumnHeader.Rows(0).BackColor = Color.Yellow
    'set locked of header as false
    FPSpread1.Sheets(0).ColumnHeader.Rows(0).Locked = False

    Regards,

    Nitin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels