ComponentOne List 8.0 for ActiveX
Anonymous style inheritance

Just as one named style can inherit font, color, and formatting characteristics from another, an anonymous style in a Split object can inherit from its counterpart in the containing TDBList control. Similarly, an anonymous style in a Column object can inherit from its counterpart in the containing Split object. Since the TDBCombo control does not have a Splits collection, the anonymous styles of its Column objects can inherit values from the control itself.

When a list is first created, its Style property inherits all of its attributes from the built-in Normal style, which controls the appearance of all data cells. Any changes to the Normal style are propagated to all splits, and in turn to the columns within each split. However, you can change the appearance of all data cells within a Split or Column object by modifying the members of its anonymous Style property.

Consider the following list layout, which uses the default values of all built-in styles and contains two identical splits.

All of the subsequent examples use this layout as a starting point. For clarity, the examples use code to illustrate the relationships between style properties and the list's display; however, you can perform the same operations at design time using the list's property pages.

Example 1:

Example Title
Copy Code
TDBList1.Style.Font.Bold = True

Since the default values of all built-in styles are in effect, columns inherit from their containing splits, which in turn inherit from the list as a whole. Therefore, this statement affects not only data cells, but all headers, footers, and caption bars. This statement has the same visual effect as changing the Normal style directly using the Style Factory property page; however, the built-in Normal style itself is not changed.

Example 2:

Example Title
Copy Code
TDBList1.Splits(0).Style.Font.Bold = True

In this example, only the data cells of the first split are affected. This is because the split caption, column headers, and column footers inherit their fonts from the built-in styles Caption, Heading, and Footing, respectively.

Example 3:

Example Title
Copy Code
With TDBList1.Splits(0)

    .Style.Font.Bold = True

    .CaptionStyle.Font.Bold = True

    .HeadingStyle.Font.Bold = True

    .FooterStyle.Font.Bold = True

End With

This example extends the previous one to render all elements of the first split in bold. In addition to the Style property, it is necessary to set the CaptionStyle, HeadingStyle, and FooterStyle properties.

Example 4:

Example Title
Copy Code
TDBList1.Splits(0).Columns(0).Style.Font.Bold = True

In this example, only the data cells of the first column of the first split are affected. This is because the column headers and column footers inherit their fonts from the built-in styles Heading and Footing, respectively.

Example 5:

Example Title
Copy Code
With TDBList1.Splits(0).Columns(0)

    .Style.Font.Bold = True

    .HeadingStyle.Font.Bold = True

    .FooterStyle.Font.Bold = True

End With

This example extends the previous one to render all elements of the first column of the first split in bold. In addition to the Style property, it is necessary to set the HeadingStyle and FooterStyle properties.

Example 6:

Example Title
Copy Code
TDBList1.Style.BackColor = &H808080

In the first example, setting the Font member of the list's Style property affected the entire list, including each caption bar, column header, and column footer. However, the same is not true of the BackColor and ForeColor properties. Since the built-in Caption, Heading, and Footing styles override both of these properties, only the data cells of the list are displayed with a dark gray background.

Example 7:

Example Title
Copy Code
TDBList1.Splits(0).Style.BackColor = &H808080

In this example, only the data cells of the first split are affected. This is because the split caption, column headers, and column footers inherit their background colors from the built-in styles Caption, Heading, and Footing, respectively.

Example 8:

Example Title
Copy Code
TDBList1.Splits(0).Columns(0).Style.BackColor = &H808080

In this example, only the data cells of the first column of the first split are affected. This is because the column headers and column footers inherit their background colors from the built-in styles Heading and Footing, respectively.

Example 9:

Example Title
Copy Code
TDBList1.Splits(0).Columns(0).Style.Alignment = dblCenter

Setting the Alignment property of a Column object affects not only its data cells, but also its header and footer. The reason for this is that the default setting of the Alignment property for the built-in Heading and Footing styles, which is inherited from Normal, is set to 3 - General. For data cells, the general setting means that the underlying data type determines whether the cell text is left, center, or right aligned; for column headers and footers, the general setting means that the column's data cell alignment should be followed.

Example 10:

Example Title
Copy Code
With TDBList1.Splits(0).Columns(0)

    .HeadingStyle.Alignment = dblLeft

    .FooterStyle.Alignment = dblRight

    .Alignment = dblCenter

End With

This example illustrates the distinction between general and specific alignment for column headers and footers. If the Alignment member of the HeadingStyle (or FooterStyle) property is not set to 3 - General, then the header (or footer) is aligned independently of the data cells.

Note that all of the preceding examples used Style object properties to demonstrate the inheritance relationships between list components. In practice, you can achieve the same results in a more straightforward manner using shortcut style properties, as described in the next section.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback