[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Controls' (#lcl)

# TControlChildSizing

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

How Child controls are to be sized relative to parent

## Declaration

Source position: controls.pp line 1531

`type TControlChildSizing = class(TPersistent)`
`protected`
`procedure Change; virtual;` |  | Change - software emulation of the OnChange event
`public`
`constructor Create();` |  | Create - constructor for TControlChildSizing: performs inherited Create then sets some default alignments and sizes
`procedure Assign(); override;` |  | Assign - if source is the same type as current control, copies a large number of explicit properties from source, else calls inherited Assign
`procedure AssignTo(); override;` |  | AssignTo - calls the Assign method for the destination control
`function IsEqual();` |  | IsEqual - returns True if the specified sizing is the same as the current value
`procedure SetGridSpacing();` |  | SetGridSpacing - specifies a value for spacing on the grid (for drawing etc)
`property Control: TWinControl; [r]` |  | The Control to which childsizing is to be applied
`property OnChange: TNotifyEvent; [rw]` |  | OnChange - event handler for a chaange in sizing
`published`
`property LeftRightSpacing: Integer; [rw]` |  | LeftRightSpacing - spacing from left to right
`property TopBottomSpacing: Integer; [rw]` |  | TopBottomSpacing - spacing from top to bottom
`property HorizontalSpacing: Integer; [rw]` |  | HorizontalSpacing - spacing in the horizontal plane
`property VerticalSpacing: Integer; [rw]` |  | VerticalSpacing - spacing in the vertical plane
`property EnlargeHorizontal: TChildControlResizeStyle; [rw]` |  | EnlargeHorizontal - make larger in the horizontal plane
`property EnlargeVertical: TChildControlResizeStyle; [rw]` |  | EnlargeVertical - make larger in the vertical plane
`property ShrinkHorizontal: TChildControlResizeStyle; [rw]` |  | ShrinkHorizontal - make smaller in the horizontal plane
`property ShrinkVertical: TChildControlResizeStyle; [rw]` |  | ShrinkVertical - make smaller in the vertical plane
`property Layout: TControlChildrenLayout; [rw]` |  | Layout - L-R then Top-Bottom, or Top-Bottom then L-R (or none)
`property ControlsPerLine: Integer; [rw]` |  | ControlsPerLine - number of controls per line
`end;`

## Inheritance

`TControlChildSizing` |  | How Child controls are to be sized relative to parent
`TPersistent`
`TObject`

## Description

    { TControlChildSizing }

      { LeftRightSpacing, TopBottomSpacing: integer;
            minimum space between left client border and left most children.
            For example: ClientLeftRight=5 means child's Left position is at least 5.

        HorizontalSpacing, VerticalSpacing: integer;
            minimum space between each child horizontally
      }

      {   Defines how child controls are resized/aligned.

          cesAnchorAligning, cssAnchorAligning
            Anchors and Align work like Delphi. For example if Anchors property of
            the control is [akLeft], it means fixed distance between left border of
            parent's client area. [akRight] means fixed distance between right
            border of the control and the right border of the parent's client area.
            When the parent is resized the child is moved to keep the distance.
            [akLeft,akRight] means fixed distance to left border and fixed distance
            to right border. When the parent is resized, the controls width is
            changed (resized) to keep the left and right distance.
            Same for akTop,akBottom.

            Align=alLeft for a control means set Left leftmost, Top topmost and
            maximize Height. The width is kept, if akRight is not set. If akRight
            is set in the Anchors property, then the right distance is kept and
            the control's width is resized.
            If there several controls with Align=alLeft, they will not overlapp and
            be put side by side.
            Same for alRight, alTop, alBottom. (Always expand 3 sides).

            Align=alClient. The control will fill the whole remaining space.
            Setting two children to Align=alClient does only make sense, if you set
            maximum Constraints.

            Order: First all alTop children are resized, then alBottom, then alLeft,
            then alRight and finally alClient.

          cesScaleChilds, cssScaleChilds
            Scale children, keep space between them fixed.
            Children are resized to their normal/advised size. If there is some space
            left in the client area of the parent, then the children are scaled to
            fill the space. You can set maximum Constraints. Then the other children
            are scaled more.
            For example: 3 child controls A, B, C with A.Width=10, B.Width=20 and
            C.Width=30 (total=60). If the Parent's client area has a ClientWidth of
            120, then the children are scaled with Factor 2.
            If B has a maximum constraint width of 30, then first the children will be
            scaled with 1.5 (A.Width=15, B.Width=30, C.Width=45). Then A and C
            (15+45=60 and 30 pixel space left) will be scaled by 1.5 again, to a
            final result of: A.Width=23, B.Width=30, C.Width=67 (23+30+67=120).

          cesHomogenousChildGrowth, cssHomogenousChildDecrease
            Enlarge children equally.
            Children are resized to their normal/advised size. If there is some space
            left in the client area of the parent, then the remaining space is
            distributed equally to each child.
            For example: 3 child controls A, B, C with A.Width=10, B.Width=20 and
            C.Width=30 (total=60). If the Parent's client area has a ClientWidth of
            120, then 60/3=20 is added to each Child.
            If B has a maximum constraint width of 30, then first 10 is added to
            all children (A.Width=20, B.Width=30, C.Width=40). Then A and C
            (20+40=60 and 30 pixel space left) will get 30/2=15 additional,
            resulting in: A.Width=35, B.Width=30, C.Width=55 (35+30+55=120).

          cesHomogenousSpaceGrowth
            Enlarge space between children equally.
            Children are resized to their normal/advised size. If there is some space
            left in the client area of the parent, then the space between the children
            is expanded.
            For example: 3 child controls A, B, C with A.Width=10, B.Width=20 and
            C.Width=30 (total=60). If the Parent's client area has a ClientWidth of
            120, then there will be 60/2=30 space between A and B and between
            B and C.
      }

The latest version of this document can be found at lazarus-ccr.sourceforge.net .