From Clomosy Docs

Revision as of 09:02, 21 October 2025 by Salih (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.
PanelAppearance.png


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:

thumb

See Also