peHeaderAlignment - cCJGridColumn

Specifies the text alignment of the column's caption and the alignment of column header's image (or icon)

Type: Property

Access: Read/Write

Data Type: XTPColumnAlignment

Parameters: None

Syntax
 Property XTPColumnAlignment peHeaderAlignment

Read Access: Get peHeaderAlignment to XTPColumnAlignmentVariable
Write Access: Set peHeaderAlignment to XTPColumnAlignmentVariable/Value


Description

Valid values are:

ConstantMeaning
xtpAlignmentDefaultAlign according to the column default (default)
xtpAlignmentLeftLeft aligns the caption
xtpAlignmentCenterCenters the caption
xtpAlignmentRightRight aligns the caption
xtpAlignmentVCenterVertically centers the caption
xtpAlignmentWordBreakThis 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.
xtpAlignmentIconLeftLeft aligns the header icon (not available when header text is right or center aligned).
xtpAlignmentIconCenterCenters the header icon (not available when header text is also displayed)
xtpAlignmentIconRightRight aligns the header icon (not available when header text is center aligned).
xtpAlignmentIconTopTop aligns the header icon.
xtpAlignmentIconVCenterVertically centers the header icon.
xtpAlignmentIconBottomBottom aligns the header icon.


By default, the column caption and header icon are aligned the same as in the column's cells. If the grid's pbUseColumnTextAlignment property is set to True and peHeaderAlignment is set to xtpAlignmentDefault, then it will be the value of the column's peTextAlignment and peIconAlignment properties which determine the column' caption and header icon alignment. If pbUseColumnTextAlignment is False, then the caption and header icon will be left aligned by default.

If peHeaderAlignment is not set to xtpAlignmentDefault, then this property's value will determine the caption and header icon alignment regardless of the grid's pbUseColumnTextAlignment setting.

Header Icon Alignment and Header Text Alignment

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.

Vertical Alignment and Multi-Row Headers

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.


Detecting Changes in Source Layout

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.

See Also

piHeaderHeightMultiplier