lirtua
asked on
control array Borland C++ Builder Visual Basic
Using Borland C++ Builder, how does one create a control array?
In Visual Basic it is very simple, just highlight the control in design view and paste it, VB asks if you want to create a control array. In Builder however, the subject of control arrays is not even mentioned in the help files. It's amazing in such a faithful reproduction of each others products, that this very helpful and simple interface was skipped over.
I would like to create 256 Panels on a Form during run time, and treat them as an array for iteration purposes.
Example source code is desirable.
Thanks in Advance:)
In Visual Basic it is very simple, just highlight the control in design view and paste it, VB asks if you want to create a control array. In Builder however, the subject of control arrays is not even mentioned in the help files. It's amazing in such a faithful reproduction of each others products, that this very helpful and simple interface was skipped over.
I would like to create 256 Panels on a Form during run time, and treat them as an array for iteration purposes.
Example source code is desirable.
Thanks in Advance:)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I hope, my info helps you. Alex
ASKER
Sorry, the controls are not showing up on my form. Here is my source code:
for(int i = 0; i < NUM_IMG; ++i)
{
image[i] = new TImage(ScrollBox1);
image[i]->Picture = Image1->Picture;
image[i]->Top = i * 10;
image[i]->Left = 10;
image[i]->AutoSize = true;
image[i]->Visible = true;
image[i]->Invalidate();
}
On the form is a scrollbox containing an image that has a bitmap loaded at design time. The control array should be located in the scrollbox and have the same pictures as the design time image.
for(int i = 0; i < NUM_IMG; ++i)
{
image[i] = new TImage(ScrollBox1);
image[i]->Picture = Image1->Picture;
image[i]->Top = i * 10;
image[i]->Left = 10;
image[i]->AutoSize = true;
image[i]->Visible = true;
image[i]->Invalidate();
}
On the form is a scrollbox containing an image that has a bitmap loaded at design time. The control array should be located in the scrollbox and have the same pictures as the design time image.
ASKER
Oh - forgot to mention this also in source code:
#define NUM_IMG 10
TImage * image[NUM_IMG];
#define NUM_IMG 10
TImage * image[NUM_IMG];
ASKER
Your code is very close. There is one thing missing though. For some reason the constructor does not set the Parent property. So we have to do this explicitly as follows:
image[i] = new TImage(sbPictureScrollBox) ;
image[i]->Parent = sbPictureScrollBox;
With this addition, the code above works.
image[i] = new TImage(sbPictureScrollBox)
image[i]->Parent = sbPictureScrollBox;
With this addition, the code above works.