Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. I need help for creating array [modified]

I need help for creating array [modified]

Scheduled Pinned Locked Moved Managed C++/CLI
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thesad
    wrote on last edited by
    #1

    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?

    C J 2 Replies Last reply
    0
    • T thesad

      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?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      T 1 Reply Last reply
      0
      • T thesad

        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?

        J Offline
        J Offline
        Jeff J Anderson
        wrote on last edited by
        #3

        array^ m; m = gcnew array(n,n);

        1 Reply Last reply
        0
        • C Christian Graus

          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 )

          T Offline
          T Offline
          thesad
          wrote on last edited by
          #4

          thank you for your help :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups