# Object Parentage

Learn about object parentage and inheritance of formatting and properties in the Spread component for effective spreadsheet management.

## Content

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 **StyleRangeStrict** 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 **StyleRangeStrict** property when it is set to true.

```csharp
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());

 }
```

```vbnet
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](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssojbects)
[Understanding Parts of the Component](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssojbects/spwin-useinterface)
[Resetting Parts of the Interface](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssojbects/spwin-cntrlresets)
[Improving Performance by Suspending the Layout](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssojbects/spwin-complayout)
[Allowing User Functionality](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssojbects/spwin-useritems)
[Allowing the User to Zoom the Display of the Component](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssojbects/spwin-cntrlzoom)
[Working with Scroll Bars](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssojbects/spwin-scroll)
[Adding a Status Bar](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssojbects/spwin-statusbar)
[Customizing Viewports](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssojbects/spwin-sheetviewports)
[Customizing Split Boxes](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssojbects/spwin-sheetsplitboxes)
[Ways to Improve Performance](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssojbects/spwin-perfimprovements)