Posted 20 November 2023, 10:31 am EST - Updated 20 November 2023, 10:36 am EST
Font color for Column header and row header
Posted by: david.sheppard on 20 November 2023, 10:31 am EST
-
-
Posted 22 November 2023, 2:23 am 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, 9: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 23 November 2023, 2:47 am 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 23 November 2023, 8:51 am EST - Updated 23 November 2023, 8:56 am EST
-
Posted 28 November 2023, 5:39 am 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, 6:21 pm EST - Updated 28 November 2023, 6:27 pm EST
I stripped all of the code out of a solution and just added back a couple of lines in the form load.
-
Posted 29 November 2023, 8:37 am 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.zipRegards,
Nitin -
Posted 29 November 2023, 9: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 30 November 2023, 8:42 am 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 30 November 2023, 8:48 am EST
Thank you.
-
Posted 19 January 2024, 11:09 am EST
I see that version 17 has been published. Has this issue been corrected in version 17?
Thank you.
-
Posted 22 January 2024, 1:29 am 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, 2:26 pm 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 11 April 2024, 12:04 am 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