From Clomosy Docs
(Created page with "<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert"> function AddNewGridLayout(AComponent: TCLComponent; xName: string): TclFlowLayout; </div> <span style="color:blue"><b>AComponent</b></span> : Specifies the parent of the object to be defined.<br> <span style="color:blue"><b>xName</b></span> : The name of the defined GridLayout should be written.<br> It is used to arrange components on the form within a fixed gri...") |
No edit summary |
||
| Line 1: | Line 1: | ||
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert"> | <div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert"> | ||
function AddNewGridLayout(AComponent: TCLComponent; xName: string): | function AddNewGridLayout(AComponent: TCLComponent; xName: string): TclGridLayout; | ||
</div> | </div> | ||
<span style="color:blue"><b>AComponent</b></span> : Specifies the parent of the object to be defined.<br> | <span style="color:blue"><b>AComponent</b></span> : Specifies the parent of the object to be defined.<br> | ||
Latest revision as of 09:02, 21 October 2025
function AddNewGridLayout(AComponent: TCLComponent; xName: string): TclGridLayout;
AComponent : Specifies the parent of the object to be defined.
xName : The name of the defined GridLayout should be written.
It is used to arrange components on the form within a fixed grid structure. Simply put, it automatically places buttons, labels, and other visual elements into rows and columns based on predefined item width and height values. When the current row or column becomes full, the layout automatically continues placing elements in the next one.
This layout ensures that all components are aligned and sized uniformly, creating a clean and balanced interface. TCLGridLayout is particularly useful when you need a consistent, grid-like arrangement of elements — for example, in dashboards, icon views, or uniform control layouts that must maintain equal spacing and proportions.
The features and usage are provided in the table below.
| Feature | Use of | Definition |
|---|---|---|
| TclGridLayout | GridLayout1 : TclGridLayout; | A variable belonging to the TclGridLayout class is created. |
| AddNewGridLayout | GridLayout1 = Form1.AddNewGridLayout(Form1,'GridLayout1'); | A new TclGridLayout is added to the form. |
| Align | GridLayout1.Align = alTop; | Specifies how the GridLayout is aligned within its parent container. Multiple alignment options are available. See the page for more details. |
| ItemHeight | GridLayout1.ItemHeight = 50; | Defines the height of each item (child control) within the grid layout. |
| ItemWidth | GridLayout1.ItemWidth = 100; | Defines the width of each item (child control) within the grid layout. |
| Margins | GridLayout1.Margins.Left = 50; // Right, Top, Bottom | Allows setting margins around the GridLayout container. |
Example
var
MyForm:TclForm;
GridLayout:TCLGridLayout;
testButton : TclButton;
I:integer;
NewHeightEdit,NewWidthEdit : TCLLabel;
ChangeSizeButton : TclButton;
void ChangeSize{
GridLayout.ItemHeight = NewHeightEdit.Text;
GridLayout.ItemWidth = NewWidthEdit.Text;
}
{
MyForm=TclForm.Create(self);
GridLayout = MyForm.AddNewGridLayout(MyForm,'GridLayout');
GridLayout.Align = alClient;
GridLayout.ItemHeight = 50;
GridLayout.ItemWidth = 50;
for (I = 0 to 10) {
testButton = MyForm.AddNewButton(GridLayout,'testButton'+IntToStr(I),'Button'+IntToStr(I));
}
NewWidthEdit = MyForm.AddNewEdit(MyForm,'NewWidthEdit', 'New Width');
NewWidthEdit.Align = alTop;
NewHeightEdit = MyForm.AddNewEdit(MyForm,'NewHeightEdit', 'New Height');
NewHeightEdit.Align = alTop;
ChangeSizeButton = MyForm.AddNewButton(MyForm,'ChangeSizeButton','Change');
ChangeSizeButton.Align = alTop;
ChangeSizeButton.Margins.Top = 20;
ChangeSizeButton.Margins.Bottom = 20;
MyForm.AddNewEvent(ChangeSizeButton,tbeOnClick,'ChangeSize');
MyForm.Run;
}
Output:
See Also
