Skip to main content
All docs
V24.2

TdxLayoutSplitterItem.OnClosed Event

Allows you to respond to a splitter collapse operation.

Declaration

property OnClosed: TdxLayoutSplitterItemMovedEvent read; write;

Remarks

Handle OnOpened and OnClosed events to execute custom code in response to splitter expand and collapse operations.

Event Occurrence

The OnClosed event occurs every time the splitter collapses its target layout item.

Event Parameters

Sender
Provides access to the layout splitter that raised the collapse event.
Args
Allows you to access layout items delimited by the Sender splitter and identify item boundaries before and after the collapse operation.

Refer to the TdxLayoutSplitterItemMovedEvent procedural type description for detailed information on all parameters accessible within an OnClosed event handler.

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;
See Also