[]
        
(Showing Draft Content)

Object Parentage

Spread allows the objects like sheets, columns/rows and cells to inherit properties from their “parent” objects such as a cell can inherit the background color from the sheet it belongs to.

However, you can override the inherited properties for individual cells. By default, objects inherit properties from their parents. So, the properties for any object are a combination of its own formatting and those inherited from its parents. For instance, a cell could have text color of its own while inheriting background color from a sheet.

Optimizing Style Storage

The object parentage enables you to optimize how the styles are stored and applied in a spreadsheet. Since formatting can be applied at various levels, such as row, column, and sheet, specific rules of precedence are followed to determine which styles take priority.

Precedence Rule

The closer the setting is to the cell level, the higher the precedence. So, if you set the background color for a cell, it will override any background color settings inherited from its parent. For example, if user set style for all cells of a column, the column style will be set instead.

The order of precedence from highest to lowest is as follows-

Cell > Row> Column> Alternating Row> Sheet> Component

Prevent Optimization of Style Storage

However, you can prevent the optimization of style by using StrictRangeStyle property. The default value of this property is false. Setting this property true allows you to style a specified cell range individually without affecting the style of object with lower precedence. For instance, the formatting applied on all cells of a column will not be set on the entire row/column.

Following code shows the behavior of StrictRangeStyle property when it is set to true.

fpSpread1.LegacyBehaviors = FarPoint.Win.Spread.LegacyBehaviors.None;
sheet = fpSpread1.AsWorkbook().ActiveSheet;
private void buttonstyle_Click(object sender, EventArgs e)
 {
    fpSpread1.AsWorkbook().Features.StyleRangeStrict = true;
    sheet.RowCount = 5;
    sheet.Rows[0, 4].Interior.Color = 
    GrapeCity.Spreadsheet.Color.FromKnownColor((GrapeCity.Core.KnownColor)KnownColor.Yellow);
    Debug.WriteLine("StyleRangeStrict: " + fpSpread1.AsWorkbook().Features.StyleRangeStrict.ToString());
    Debug.WriteLine("Columns[0].Interior.Color: " + sheet.Columns[0].Interior.Color.ToString());

 }
FpSpread1.LegacyBehaviors = FarPoint.Win.Spread.LegacyBehaviors.None
sheet = FpSpread1.AsWorkbook().ActiveSheet

Private Sub buttonstyle_Click(ByVal sender As Object, ByVal e As EventArgs)
      FpSpread1.AsWorkbook().Features.StyleRangeStrict = True
      sheet.RowCount = 5
      sheet.Rows(0, 4).Interior.Color = 
      GrapeCity.Spreadsheet.Color.FromKnownColor(CType(KnownColor.Yellow, GrapeCity.Core.KnownColor))
      Debug.WriteLine("StyleRangeStrict: " & FpSpread1.AsWorkbook().Features.StyleRangeStrict.ToString())
      Debug.WriteLine("Columns[0].Interior.Color: " & sheet.Columns(0).Interior.Color.ToString())

End Sub

Limitation

It only takes effect when LegacyBehaviors.All is excluded from LegacyBehaviors enum.

See Also

Spreadsheet Objects

Understanding Parts of the Component

Resetting Parts of the Interface

Improving Performance by Suspending the Layout

Allowing User Functionality

Allowing the User to Zoom the Display of the Component

Working with Scroll Bars

Adding a Status Bar

Customizing Viewports

Customizing Split Boxes

Ways to Improve Performance