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. C#
  4. Array

Array

Scheduled Pinned Locked Moved C#
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.
  • S Offline
    S Offline
    shamsteady
    wrote on last edited by
    #1

    I declare "private System.Windows.Forms.Panel mypanel;" in window form to get a panel name my panel. Can i declare "System.Windows.Forms.Panel [] mypanel;" to get an array of panel because i want to generate couple of mypanel during runtime...

    T 1 Reply Last reply
    0
    • S shamsteady

      I declare "private System.Windows.Forms.Panel mypanel;" in window form to get a panel name my panel. Can i declare "System.Windows.Forms.Panel [] mypanel;" to get an array of panel because i want to generate couple of mypanel during runtime...

      T Offline
      T Offline
      Travis D Mathison
      wrote on last edited by
      #2

      Yes you can, you just have to remember to new up each panel in the array prior to use...

      S 1 Reply Last reply
      0
      • T Travis D Mathison

        Yes you can, you just have to remember to new up each panel in the array prior to use...

        S Offline
        S Offline
        shamsteady
        wrote on last edited by
        #3

        Thanks for the useful information

        C 1 Reply Last reply
        0
        • S shamsteady

          Thanks for the useful information

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

          However, it's not really going to work. To do this, you need when you create each Panel, pass it into the forms Controls collection, and it's often easier just to create Panels and find them from the Controls collection. foreach(Control c in Controls) { if (c is Panel) { } // OR Panel p = c as Panel; if (p != null) { } }

          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 )

          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