How to Use Styles > Working with Style Properties > Modifying a style property directly |
You can customize the appearance of a grid component by modifying one or more members of an appropriate style property. For example, to make the grid's caption text bold, you can change the Font object associated with the CaptionStyle property. At design time, this is done by expanding the CaptionStyle tree node on the General property page, selecting the Font node, and checking the Bold box. The change is committed to the grid when you click the OK or Apply button or select a different property page tab.
Note that the text of the CaptionStyle node ends with the word Caption enclosed in square brackets. This indicates that the property inherits some or all of its attributes from a like-named member of the Styles collection. However, if you switch to the Style Factory property page, you will see that the built-in Caption style has not changed.
This means that the following statements are not equivalent:
Example Title |
Copy Code
|
---|---|
TDBGrid1.CaptionStyle.Font.Bold = True
TDBGrid1.Styles("Caption").Font.Bold = True
|
The first statement specializes the font of the grid's caption bar without changing the named Caption style. The second statement changes the named Caption style, which may or may not affect the display of the grid's caption bar, depending on whether the Font member of the CaptionStyle property was specialized previously. For example, if you change the grid's CaptionStyle font to Arial, then change the font of the built-in Caption style to Courier, the grid caption will remain Arial. However, if you never change the CaptionStyle font, then any font change to the built-in Caption style will be instantly reflected in the grid's caption bar.