Property XTPColumnAlignment peHeaderAlignment
| Read Access: | Get peHeaderAlignment to XTPColumnAlignmentVariable |
| Write Access: | Set peHeaderAlignment to XTPColumnAlignmentVariable/Value |
Valid values are:
| Constant | Meaning |
|---|---|
| xtpAlignmentDefault | Align according to the column default (default) |
| xtpAlignmentLeft | Left aligns the caption |
| xtpAlignmentCenter | Centers the caption |
| xtpAlignmentRight | Right aligns the caption |
| xtpAlignmentVCenter | Vertically centers the caption |
| xtpAlignmentWordBreak | This allows the caption text to "wrap" if the width of the column is not wide enough to display the text. This specifies that line breaks are allowed. |
| xtpAlignmentIconLeft | Left aligns the header icon (not available when header text is right or center aligned). |
| xtpAlignmentIconCenter | Centers the header icon (not available when header text is also displayed) |
| xtpAlignmentIconRight | Right aligns the header icon (not available when header text is center aligned). |
| xtpAlignmentIconTop | Top aligns the header icon. |
| xtpAlignmentIconVCenter | Vertically centers the header icon. |
| xtpAlignmentIconBottom | Bottom aligns the header icon. |
Caption alignment and icon alignment constants may be combined in order to align caption text and header icons. For example:
Set peHeaderAlignment to (xtpAlignmentIconRight + xtpAlignmentRight)
This would right align the caption text and header icon. The header icon will appear to the right of the caption.
Note that header icon alignment is affected by the caption alignment. By default, if only the caption alignment is specified, the icon alignment follows the caption alignment where the icon is displayed to the left of the caption text. The following restrictions apply.
1) When there is caption text displayed then the icon cannot be center aligned unless the caption is also center aligned.
2) When caption is right aligned then the header icon cannot be left aligned.
Each of the Left, Center or Right text alignment constants can be combined with the WordBreak and VCenter alignment constants. For example:
Set peHeaderAlignment to (xtpAlignmentCenter + xtpAlignmentVCenter + xtpAlignmentWordBreak)
The xtpAlignmentWordBreak constant allows the header text to wrap to multiple rows. You must also set the grid object's piHeaderHeightMultiplier property to increase the overall height of the grid header.
Wrapped text is always left aligned, the right or center alignment constants only apply when the column is wide enough to display all the header text on one line. The VCenter constant ensures that single line header text is vertically centered in the case where the grid header spans multiple lines.
A column's header text is assigned by setting the psCaption property.
To assign an image, or icon, to a column header set the psImage property.
In order to display a header section, the grid object's pbShowHeader property must be set True.
Setting pbMultiLine to True and peHeaderAlignment to xtpAlignmentWordBreak can also provide multi-line word wrapping in the grid header. Since setting pbMultiLine to True negatively impacts the painting performance of your grid, this is not the recommended technique for supporting multi-line text in the header. You should only use this approach if you are already displaying multi-line text in the report body.
The preferred technique for supporting multi-line text (or large icons) in the grid header is to set the grid's piHeaderHeightMultiplier property. This allows you to enlarge the header without impacting the grid's painting performance. Do not use piHeaderHeightMultiplier in combination with pbMultiLine set to True, otherwise the header height cannot be calculated correctly.
When source code changes are made in a grid, the restored layout may interfere with those changes. When this happens, changes made to the grid and its columns will not appear because the old settings are being restored. The grid class attempts to recognize when such a change has occurred by checking if the number of columns has changed. If it has, the previous setting will not be restored. This only catches a small number of the possible changes and it is quite likely that it will not recognize that a change has actually occurred. When this occurs, it will appear that the grid is ignoring your source code changes. The number of columns that appear may be wrong, the ordering and size of the columns may be wrong and some of the grid alignment settings will be wrong.
If this happens, you must tell the system that the menu layout has changed. You can do this by changing (i.e., incrementing) the build number of the grid system by setting the piLayoutBuild property.
During development, it is probably best to disable the loading and saving of the grid's environment. Set pbRestoreLayout of the grid object to False to turn off restore layout for a grid, or set pbPreserveEnvironment of the cApplication object to False to disable restore layout for your entire application.