Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 961443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:20:40+00:00 2026-05-16T01:20:40+00:00

i have create 7 dynamic buttons in a scroll box. Each row need to

  • 0

i have create 7 dynamic buttons in a scroll box. Each row need to have 2 buttons (number of buttons may change) only, but the result of the code below shows the first row with 2 buttons but all the rest in 2nd row, how should i fixed it to 2 buttons 1 row?

procedure TForm1.CreateDynamicBtn2;
var
   abtn: TBitBtn;
   i, j, iNum, iCount : integer;
begin
  if ScrollBox2.ControlCount > 0 then begin
       for j := ScrollBox2.ControlCount - 1 downto 0 do begin
          with ScrollBox2.Controls[j] AS TBitBtn do begin
            Free;
          end;
       end;
    end;
  iCount := 0;
  for i := 0 to 6 do begin
    iNum := i + 1;
    abtn := TBitBtn.Create(self);
    abtn.Parent := ScrollBox2;
    abtn.Visible := True;
    abtn.Caption := 'dynamic' + IntToStr(i);

    if iNum*abtn.Width > (iCount+2)*abtn.Width then begin
       iCount := iCount + 1;
       abtn.Left := (iCount * abtn.Width) - abtn.Width;
       abtn.Top  := abtn.Height;
    end else begin
       abtn.Left := i * abtn.Width;
       abtn.Top  := 0;
    end;
  end;
end; 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:20:41+00:00Added an answer on May 16, 2026 at 1:20 am

    Because you are making things way too complicated?

    abtn.Left := (i mod 2) * abtn.Width;
    abtn.Top := Trunc((i div 2)) * abtn.Height;
    

    Should do the trick nicely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have create 5 dynamic buttons in 1 row and store the button info
i have created 4 dynamic buttons but how to write method on each of
I have recently learned to create dynamic links via php, but my problem today
So here is the problem: I am trying to create dynamic buttons that have
I need to create dynamic 'Pay Now' buttons on my site, and PayPal says
I have a dynamic application that need to create a window interface with checkbox.
We are creating dynamic text boxes and buttons inside a grid for each row.
I need to create dynamic radio button in my table.I have a table in
I have create dynamic listview based on database but the problem is to load
I have create a number of buttons on an iPhone view in the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.