calculate position of TButton's on a TForm lazarus / 21-General ---------------------------------------------------------------------- paule32 · 2025-04-22 16:18 Hello, I have an Array of TButton's (10 TButton) Now, I would place them horizontal on the Form with a for loop. How can I do this, when I have only the Counter Variable btnCount ? The Buttons shall have a gap of 10 Pixels on each. ---------------------------------------------------------------------- Remy Lebeau · 2025-04-22 16:24 Quote from: paule32 on April 22, 2025, 06:18:24 pmI have an Array of TButton's (10 TButton) Now, I would place them horizontal on the Form with a for loop. How can I do this, when I have only the Counter Variable btnCount ? The Buttons shall have a gap of 10 Pixels on each. Something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  iLeft, iTop, idx: Integer;  arr: array of TButton;  btn: TButton;begin  arr := ...;  iLeft := ...; // desired starting position  iTop := ...; // desired starting position  for idx := Low(arr) to High(arr) do  begin    btn := arr[idx];    btn.Left := iLeft;    btn.Top := iTop;    Inc(iLeft, btn.Width + 10);  end;end; Or: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  iLeft, iTop: Integer;  arr: array of TButton;  btn: TButton;begin  arr := ...;  iLeft := ...; // desired starting position  iTop := ...; // desired starting position  for btn in arr do  begin    btn.Left := iLeft;    btn.Top := iTop;    Inc(iLeft, btn.Width + 10);  end;end; ---------------------------------------------------------------------- wp · 2025-04-22 17:28 In Lazarus the container controls have a little-known property named ChildSizing (https://wiki.freepascal.org/Autosize_/_Layout#Layout). It helps to automatically position controls in this container. I guess you do not want to fill the form completely by the 10 buttons. Therefore, I'd propose to add a TPanel to the form which will serve as a container for the buttons. Go to property ChildSizing of the panel. Set its "ControlsPerLine" to 10 (or 5, if you want to have the buttons in two rows), and set "Layout" to "cclLeftToRightThenTopToBottom". Now drop the 10 buttons on the panel - each button will be automatically positioned and prefectly aligned. In order to control the spacing between the buttons enter their distance in "HorizontalSpacing" (and "VerticalSpacing" if you have multiple rows). If you want to rearrange the button order, select the button to be moved and press Ctrl+PgUp or Ctrl+PgDown. Finally set the panel's AutoSize to true, and you may probably also want to bottom-align the panel (Align = alBottom, or similar). ---------------------------------------------------------------------- paule32 · 2025-04-22 19:33 Thanks Remy ---------------------------------------------------------------------- lainz · 2025-04-23 02:53 Thanks wp is the solution I wanted to write