Skip to main content

TdxLayoutSplitterItem Class

A splitter that delimits two adjacent layout items.

Declaration

TdxLayoutSplitterItem = class(
    TdxLayoutDirectionalItem
)

Remarks

A splitter is an auxiliary layout item that allows you to delimit two layout items and resize them without the Customization Form.

Near, Far, and Target Layout Items

Near and far item positions depend on the parent layout group‘s LayoutDirection property value:

ldVertical
Default. The group arranges items from top to bottom. The near item is above the splitter, and the far item is below it.
ldHorizontal
The group arranges items from left to right. Near and far items are to the left and right of a splitter, respectively.

The target item is the near or far layout item associated with the splitter, depending on AlignVert and AlignHorz property values as well as the parent group direction.

For example, the near item is the splitter target if the parent group is horizontally arranged, and the AlignHorz property is set to ahLeft:

VCL Layout Control: A Splitter and Delimited Layout Groups

Main API Members

The list below outlines key members of the TdxLayoutSplitterItem class. These members allow you to configure the layout splitter and manage its states.

User Interaction Options

AllowCloseOnClick
Specifies if a click on the splitter expands or collapses the target layout item.
OnCanResize
Allows you to prevent users from resizing layout items delimited by the splitter.

Splitter State Management

Close | IsClosed | Open
Collapse and expand the splitter’s target layout item.
OnClosed | OnMoved | OnOpened
Allow you to respond to splitter collapse, expand, and move operations.

General-Purpose API Members

AlignHorz | AlignVert
Specify the target layout item in horizontally and vertically arranged parent groups.
GetFarItem | GetNearItem
Provide access to layout items delimited by the splitter.
Visible
Specifies if the layout splitter is visible.

Code Examples

Track Splitter Movement

The following code example demonstrates an OnMoved event handler that displays names and sizes of layout items delimited by the currently dragged splitter in a horizontally arranged layout group:

procedure TMyForm.dxLayoutSplitterItem1Moved(
  Sender: TdxLayoutSplitterItem; AArgs: TdxLayoutSplitterItemMovedEventArgs);
begin
  Caption := AArgs.NearItem.Name + ' Item Width: ' + IntToStr(AArgs.NewNearItemBounds.Width) + ' ' +
    AArgs.FarItem.Name + ' Item Width: ' + IntToStr(AArgs.NewFarItemBounds.Width);
end;

Keep Only One Grouped Layout Item Expanded at a Time

The code example in this section demonstrates OnClosed and OnOpened event handlers that allow you to keep only one layout item expanded within a layout group that contains items delimited by splitters. The form’s OnCreate event handler assigns the same event handlers to all splitters within the target group.

procedure TMyForm.SplitterItemClosed(Sender: TdxLayoutSplitterItem;
  AArgs: TdxLayoutSplitterItemMovedEventArgs);
var
  I: Integer;
begin
  for I := 0 to dxLayoutGroup1.Count - 1 do
    if((dxLayoutGroup1.Items[I].ClassType = TdxLayoutSplitterItem) and
      (dxLayoutGroup1.Items[I] <> Sender)) then
      if (dxLayoutGroup1.Items[I] as TdxLayoutSplitterItem).IsClosed then
        (dxLayoutGroup1.Items[I] as TdxLayoutSplitterItem).Open;
end;

procedure TMyForm.SplitterItemOpened(Sender: TdxLayoutSplitterItem;
  AArgs: TdxLayoutSplitterItemMovedEventArgs);
var
  I: Integer;
begin
  for I := 0 to dxLayoutGroup1.Count - 1 do
    if ((dxLayoutGroup1.Items[I].ClassType = TdxLayoutSplitterItem) and
       (dxLayoutGroup1.Items[I] <> Sender)) then
       if not (dxLayoutGroup1.Items[I] as TdxLayoutSplitterItem).IsClosed then
         (dxLayoutGroup1.Items[I] as TdxLayoutSplitterItem).Close;
end;

procedure TMyForm.FormCreate(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to dxLayoutGroup1.Count - 1 do
    if(dxLayoutGroup1.Items[I].ClassType = TdxLayoutSplitterItem) then
    begin
      (dxLayoutGroup1.Items[I] as TdxLayoutSplitterItem).AllowCloseOnClick := True;
      (dxLayoutGroup1.Items[I] as TdxLayoutSplitterItem).OnOpened := SplitterItemOpened;
      (dxLayoutGroup1.Items[I] as TdxLayoutSplitterItem).OnClosed := SplitterItemClosed;
    end;
end;

Other Auxiliary Layout Items

TdxLayoutEmptySpaceItem
An auxiliary layout item used to provide an empty region within a layout control.
TdxLayoutImageItem
An auxiliary layout item used as an image container.
TdxLayoutSeparatorItem
A separator used to visually separate layout elements into small, logical groups within a layout group.
TdxLayoutLabeledItem
A standalone label that can be associated with any layout element.
See Also