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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:21:39+00:00 2026-06-02T06:21:39+00:00

OK, I’m trying to create some custom number of TPanel’s at runtime on TScrollBox

  • 0

OK, I’m trying to create some custom number of TPanel’s at runtime on TScrollBox surface like you can see on following image.

enter image description here

To get this I’m using following code and that works fine.

var
  pan: array of TPanel;
  maxp, i, x, y: Integer;

...

maxp := 10;
SetLength(pan, maxp);

for i := 1 to maxp do begin
  // x is correct value; doesn't cause problem
  // y is correct value; doesn't cause problem
  pan[i-1] := TPanel.Create(form1);
  with pan[i-1] do begin
    Width := 100;
    Height := 150;
    Top := x * 151;
    Left := y * 101;
    Parent := ScrollBox1;
    end;
  end;

Now, I have problems to put TImage object in every TPanel with same index (img[0] -> pan[0], img[1] -> pan[1], etc). Look at the following image:

enter image description here

Using same logic, I’ve tried to create TImage’s but w/ no success.

I’m using this code and cant figure out what’s wrong. It looks so simple to me, but somehow it doesn’t provide expected effect.

var
  pan: array of TPanel;
  img: array of TImage;
  maxp, i, x, y: Integer;

...

maxp := 10;
SetLength(pan, maxp);
SetLength(img, maxp);

for i := 1 to maxp do begin
  // x is correct value; doesn't cause problem
  // y is correct value; doesn't cause problem
  pan[i-1] := TPanel.Create(form1);
  with pan[i-1] do begin
    Width := 100;
    Height := 150;
    Top := x * 151;
    Left := y * 101;
    Parent := ScrollBox1;
    end;
  img[i-1] := TImage.Create(form1);
  with img[i-1] do begin
    Width := 98;
    Left := 1;
    Height := 148;
    Top := 1;
    // in original code next line had img[0]. which caused problem
    Picture.LoadFromFile('some_image_file');
    Parent := pan[i-1];
    end;
  end;

Somehow it places all TImage objects on same place in first TPanel (pan[0]). It’s confusing for me because it says Parent := pan[i-1]; but for some reason it always puts TImage in pan[0]. I’ve tried using breakpoints to see what’s going on after every for-loop cycle (added Application.ProcessMessages at the end) and it really creates 10 different images but puts them onto pan[0]. Of course, at the end it shows just last image loaded into pan[0].

My question is how to make one dynamic TImage per dynamic TPanel (with same array indices)?

SOLVED!

  • 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-06-02T06:21:43+00:00Added an answer on June 2, 2026 at 6:21 am

    Ah, I found it… how blind I am really…

    To get auto-complete in delphi, i’ve used img[0] in front of Picture.LoadFromFile(). Then, obviously I forgot to remove it from code, and since hour ago that ‘prefix’ stayed there making all images load into same img[0]. I was sure there’s something wrong with Parent or Pos/Size properties and have been focused on this things not caring so much about this.

    I actually had

      with img[i-1] do begin
        Width := 98;
        Left := 1;
        Height := 148;
        Top := 1;
        img[0].Picture.LoadFromFile('some_image_file');
        Parent := pan[i-1];
        end;
    

    But somehow I’ve removed that img[0] part while posting this question, and haven’t seen it as problem in my Delphi code. Obviously, when I was formatting this code, i removed some parts and that made answering my question here impossible 🙁

    Really sorry for bothering you guys, that was my bad.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string

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.