Populating Array of Buutons

I have a 100 buttons that I have already have created they are button1, button2 and so on.I have created a two dem button array. I was wondering what would be the best way to populate the button array for instance

button 1 -10
button 11 - 20
button 21 - 30

and so on.
this is how I am trying to do it

1
2
3
4
5
6
7
8
9
10
11
void Array_Population()
		{
			array<Button^, 2>^ btn = gcnew array<Button^, 2>(10, 10);
			for (int x = 0; x < 10; ++x)
			{
				for(int y = 0; y < 10; ++y)
				{
					btn[x, y] = button1;
				}
			}
		}
Last edited on
You can access a button by name like this:
 
   Button^ btn = (Button^) this->Controls["Button1"];

All you have to is to use a loop and contruct the name there.
1
2
3
4
5
for (int i = 1; i <= 100; i++)
{
   String^ name = "Button" + i.ToString();
   // use Controls[name];
}
Topic archived. No new replies allowed.