TdxLayoutSplitterItem.Close Method
Collapses the splitter’s target layout item.
Declaration
procedure Close;
Remarks
You can call Open and Close
procedures to expand or collapse the splitter’s target layout item. Alternatively, you can set the IsClosed property to True
or False
to collapse or expand the target layout item.
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:
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;