Creating an array of objects

How do I create an array of objects?
I have 21 text boxes that need to be filled from 7 class objects. I want to step through the objects in sequence, check the value of a member variable, and if that is true, display the name in the box.
Is this something I need to use pointers for? What is the syntax for declaring and accessing the array?
I am writing a Windows Form in VC++2008
The class I want to use is below.
1
2
3
4
5
6
7
ref struct block{
	System::String^ name;
	System::Boolean enabled1;//Enabled on the first loop
	System::Boolean enabled2;//Enabled on the second loop
	System::Boolean enabled3;//Enabled on the third loop
	System::Int32 sequence;
	System::Int32 length;};

So, in the object "Union", I want to check if enabled1 is true. If so, then set this->box1->Text=Union.name. If not, check "High"; if High.enabled1==true , then this->box1->Text=High.name,etc. Then, repeat the cycle at TextBox8 and following.
Thank you.
If you want to loop through controls on a form you can use something like
for each(Control^ con in this->Controls)
I am assuming your using c++/cli from the code you posted.
to create appropriate cli array try:

array<TextBox ^, 1> ^ ar = gcnew array<TextBox ^, 1>(21);

ar[0] = this->box1;
ar[1] = this->box2;
...
ar[20] = this->box21;

then you can loop through with convential for loop or containers for each loop.

using for each is faster than using convential for loop logic.
Topic archived. No new replies allowed.