Why does setting the BackColor on the spread have no effect

Posted by: j2associates on 8 September 2017, 12:39 pm EST

  • Posted 8 September 2017, 12:39 pm EST

    Hello All,


    After searching the board I found that to change the displayed background color, you need to use ActiveSheet.DefaultStyle.BackColor = MyColor or else set the BackColor of a created Style object and then apply that Style to the ActiveSheet object. This doesn't make sense to me. If I set the BackColor on the FpSpread, why would that not ripple down and become the DefaultStyle.BackColor for all of the sheets? Thanks in advance for any ideas and/or suggestions!

  • Replied 8 September 2017, 12:39 pm EST

    j2 -

    The sheetview is a class of it's own so it would not inherit the settings of the spread object.
  • Replied 8 September 2017, 12:39 pm EST

    If that is the case, why is BackColor and ForeColor exposed as properties for FpSpread since they don't appear to do anything? I'm not trying to be argumentative here, but the properties appear to be misleading since setting them don't appear to change anything when the spread is displayed, unless I am missing something here. Thanks again!

  • Replied 8 September 2017, 12:39 pm EST

    j2 -

    Since spread inherits from the Control class those properties are inherited.  If you were to set the sheetcount = 0 and set the backcolor property you would see it.
  • Replied 8 September 2017, 12:39 pm EST

    j2associates,


    Many simple controls (e.g. text box) only have a single area.  These simple controls use the BackColor property.


    Some complex controls (e.g. grid or spreadsheet) have multiple areas (e.g. row header cells, column header cells, content cells, grouping area, area between last row/column and scroll bar, etc) with each area needing a different background color.  These complex controls often ignore the BackColor property in favor of specialized properties for each area.  For example, Microsoft's DataGridView ignores the BackColor property and instead uses BackgroundColor, DefaultCellType.BackColor, etc.


    Note:  Since all controls inherit from the Control class and the Control class exposes the BackColor properties, even controls that ignore the BackColor property will still expose the BackColor.  Again, look at Microsoft's DataGridView control.

  • Replied 8 September 2017, 12:39 pm EST

    Thanks, that makes sense.
Need extra support?

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

Learn More

Forum Channels