I need help for creating array [modified]
-
I need to create an 2 dimension array, wich type is picture box, so I have write such code:
private: static unsigned short int n = 100; private: static array < System::Windows::Forms::PictureBox^ >^ m; m = gcnew array < System::Windows::Forms::PictureBox^ > (n); for(int i=0; i < n; i++){ m[i] = gcnew array < System::Windows::Forms::PictureBox^ >(n); for( int j = 0; j < n; j++){ m[i, j] = gcnew System::Windows::Forms::PictureBox(); m[i, j]->Location = System::Drawing::Point(200 + i, 250); m[i, j]->Visible = true; m[i, j]->Size = System::Drawing::Size(1, 1); m[i, j]->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage; m[i, j]->Load("a.gif"); Controls->Add(m[i, j]); } }
but i get an error, that this array is not 2 dimension what can be wrong? -
I need to create an 2 dimension array, wich type is picture box, so I have write such code:
private: static unsigned short int n = 100; private: static array < System::Windows::Forms::PictureBox^ >^ m; m = gcnew array < System::Windows::Forms::PictureBox^ > (n); for(int i=0; i < n; i++){ m[i] = gcnew array < System::Windows::Forms::PictureBox^ >(n); for( int j = 0; j < n; j++){ m[i, j] = gcnew System::Windows::Forms::PictureBox(); m[i, j]->Location = System::Drawing::Point(200 + i, 250); m[i, j]->Visible = true; m[i, j]->Size = System::Drawing::Size(1, 1); m[i, j]->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage; m[i, j]->Load("a.gif"); Controls->Add(m[i, j]); } }
but i get an error, that this array is not 2 dimension what can be wrong?To create it in two dimensions, you need to create an array of arrays. private: static array < array < System::Windows::Forms::PictureBox^> >^ m;
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
I need to create an 2 dimension array, wich type is picture box, so I have write such code:
private: static unsigned short int n = 100; private: static array < System::Windows::Forms::PictureBox^ >^ m; m = gcnew array < System::Windows::Forms::PictureBox^ > (n); for(int i=0; i < n; i++){ m[i] = gcnew array < System::Windows::Forms::PictureBox^ >(n); for( int j = 0; j < n; j++){ m[i, j] = gcnew System::Windows::Forms::PictureBox(); m[i, j]->Location = System::Drawing::Point(200 + i, 250); m[i, j]->Visible = true; m[i, j]->Size = System::Drawing::Size(1, 1); m[i, j]->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage; m[i, j]->Load("a.gif"); Controls->Add(m[i, j]); } }
but i get an error, that this array is not 2 dimension what can be wrong?array^ m; m = gcnew array(n,n);
-
To create it in two dimensions, you need to create an array of arrays. private: static array < array < System::Windows::Forms::PictureBox^> >^ m;
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )