how to show 2D array in Windows form GUI?

Apr 22, 2011 at 6:24pm
hi everyone i am making a game that i need to show an 2D array using GUI.
for example, i create an 2D array field[10][10]
this array contain 100elements of interger range from 1 to 9.
i want to show it on the GUI form but i dont know how to do it...
i hv try to make some lebal so lebal will show element of array like that

lebal->Text1=""+field[0][0]

but that is not practical to make 100 lebel...
is there better way to show that?

are there any way just like command line such as
1
2
3
4
5
6
7
8
for(int r=0;r<=9;r++)
{
for(int c=0;c<=9;c++)
{
cout<<field[r][c]<<" ";
}
cout<<endl;
}
Apr 23, 2011 at 7:17am
That depends on what GUI library you are using. One would usually make GUI dynamically in cases like yours. The position of these Gooeys are usually computed throught simple loop..

1
2
3
4
5
6
const FIX_WIDTH = 80; //this could represent pixels or other measuring unit
for (int i=0; i<10; i++)
{
  posx = FIX_WIDTH * i;
  //position your Gooey. . .
}
Apr 23, 2011 at 9:31am
I supose as it is a GUI program - he could use something like a Listview control
Apr 23, 2011 at 9:59am
thanks for reply!
i am using vs2010 for my GUI form designing.
Topic archived. No new replies allowed.