Skip to main content

TdxLayoutSplitterItem.AllowCloseOnClick Property

Specifies if a click on the splitter collapses its target layout item.

Declaration

property AllowCloseOnClick: Boolean read; write; default False;

Property Value

Type Default Description
Boolean False

True if the splitter can collapse its target layout item; otherwise, False.

Remarks

Set the AllowCloseOnClick property to True to allow users to collapse or expand a layout item with a click on the splitter. Alternatively, you can check the Collapsible item in the splitter item’s context menu in the Customization Form.

VCL Layout Control: The Collapsible Option in the Customization Form

Property Values

False

Default. A click on the splitter item has no effect. A user can only drag the splitter to resize the associated layout element. If the AllowCloseOnClick property is set to False while the splitter is collapsed, the splitter automatically expands its layout element to the original size (before the previous collapse operation).

VCL Layout Control: Layout Item Collapse Operations are Disabled

True

The splitter item displays an arrow that indicates the direction of the collapse or expand operation. A click on the splitter collapses its associated layout element. A subsequent click on the same splitter expands the collapsed layout item to its original size. Alternatively, a user can drag the collapsed splitter in the arrow’s direction to expand the layout element to any size.

VCL Layout Control: Layout Item Collapse Operations are Enabled

Code Example: 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;

Notes and Limitations

  • The collapsed splitter automatically expands the target item when it is associated with another layout item.
  • A click on the splitter item does not raise the OnCanResize event.
  • The AllowCloseOnClick property value does not affect the IsClosed property as well as Open and Close procedures. You can always expand or collapse the target layout item in code.

Default Value

The AllowCloseOnClick property’s default value is False.

See Also