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 6121007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:44:05+00:00 2026-05-23T15:44:05+00:00

I have created one TScrollBox. I have added the Label and Edit Box on

  • 0

I have created one TScrollBox. I have added the Label and Edit Box on it dynamically on Button click. For setting the location of component i have used the height,width,left,top property of components.
But when Scroll Bar gets appeared on screen after 5 components added, the next components location gets disturbed. and the next component is not placed in synchronous manner on ScrollBox.

  • 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-23T15:44:05+00:00Added an answer on May 23, 2026 at 3:44 pm

    The Top coordinate for controls placed on a ScrollBox need to take into account the amount of “scroll” that already took place. If you add the controls all at once this is not a problem, because the ScrollBox doesn’t get the chance to “scroll”.

    If you add controls to the ScrollBox after it got a chance to “scroll”, you need to take into account the amount of vertical “scroll” that took place. Here’s a sample piece of code that will add labels to ScrollBox1, taking vertical scroll into account so controls don’t overlap each other. Here I’m using the form’s “Tag” property to hold the Top for the next control added, and I’m also using Tag to generate unique names for the labels (so you can see they’re going into the ScrollBox at the correct coordinates).

    procedure TForm31.Button1Click(Sender: TObject);
    var L: TLabel;
    begin
      L := TLabel.Create(Self);
      L.Caption := 'Test: ' + IntToStr(Tag);
      L.Parent := ScrollBox1;
      L.Top := Tag + ScrollBox1.VertScrollBar.Size - ScrollBox1.VertScrollBar.Position;
      Tag := Tag + L.Height;
    end;
    

    An other approach I sometimes used is to keep track of the last control added and base the coordinates for the new control on the coordinates of that last added control:

    var LastControl: TControl;
    
    procedure TForm31.Button1Click(Sender: TObject);
    var L: TLabel;
    begin
      L := TLabel.Create(Self);
      L.Caption := 'Test: ' + IntToStr(Tag);
      L.Parent := ScrollBox1;
      if Assigned(LastControl) then
        L.Top := LastControl.Top + LastControl.Height
      else
        L.Top := 0;
      Tag := Tag + L.Height;
    
      LastControl := L;
    end;
    

    And yet an other approach would be to find the lowest control and add your control based on it’s coordinates:

    procedure TForm31.Button1Click(Sender: TObject);
    var L: TLabel;
        Bottom, TestBottom: Integer;
        i: Integer;
    begin
      // Find "Bottom"
      Bottom := 0;
      for i:=0 to ScrollBox1.ControlCount-1 do
        with ScrollBox1.Controls[i] do
        begin
          TestBottom := Top + Height;
          if TestBottom > Bottom then
            Bottom := TestBottom;
        end;
      L := TLabel.Create(Self);
      L.Caption := 'Test: ' + IntToStr(Tag);
      L.Parent := ScrollBox1;
      L.Top := Bottom;
      Tag := Tag + L.Height;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created one button component using one Bitmap and one Label in it.
I have created one jsp form which contains the username textfield. On the click
I have created one dynamic button in my application and I call the following
I have created one application in j2me, I have used json parsing in that
I have created one gridview and use custom adapter for that. I added two
We have created one temp-table dynamically . and we want to out put the
I have created one dropdown box <select name=select id=selectId> <option id= value=calendar_Second_Calendar_1285942672.xml>Second Calendar</option> <option
I have created one html form with following fields: Name (Text Box) Email (Text
I have created one web app using mvc and in that used form authentication
I have created one sample application , based on UIWebview sample and i added

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.