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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Checkbox Arrays...

Checkbox Arrays...

Scheduled Pinned Locked Moved C#
questioncsharpdata-structures
3 Posts 2 Posters 1 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.
  • F Offline
    F Offline
    flicktom
    wrote on last edited by
    #1

    Ok, this is a simple question, but I've tried and looked and just can't seem to come up with an answer... In my VB6 app, I can create an array of controls simply by copy and pasting for the default "do you want to make this object an array" prompt... In C#, I get no prompt, and no menu option (that I can see.. maybe I'm blind) to make an array. I simply want to be able to create an array of x number of checkboxes (or any control, for that matter) in a panel so I can cycle through them with an iteration statement... What am I missing? If this involves more code than using iteration would save, just tell me and I'll move on. Thanks in advance. :)

    F J 2 Replies Last reply
    0
    • F flicktom

      Ok, this is a simple question, but I've tried and looked and just can't seem to come up with an answer... In my VB6 app, I can create an array of controls simply by copy and pasting for the default "do you want to make this object an array" prompt... In C#, I get no prompt, and no menu option (that I can see.. maybe I'm blind) to make an array. I simply want to be able to create an array of x number of checkboxes (or any control, for that matter) in a panel so I can cycle through them with an iteration statement... What am I missing? If this involves more code than using iteration would save, just tell me and I'll move on. Thanks in advance. :)

      F Offline
      F Offline
      flicktom
      wrote on last edited by
      #2

      Ok... I found the C# tutorial on how to create a group of controls from a string array... Is this the only way to create and use an array of controls? I'd really much prefer to have them available at design time, not to mention having to plot their location every time I want to create another array of controls. I find it hard to believe that .NET would make something that seems so fundamental such a pain in the arse...

      1 Reply Last reply
      0
      • F flicktom

        Ok, this is a simple question, but I've tried and looked and just can't seem to come up with an answer... In my VB6 app, I can create an array of controls simply by copy and pasting for the default "do you want to make this object an array" prompt... In C#, I get no prompt, and no menu option (that I can see.. maybe I'm blind) to make an array. I simply want to be able to create an array of x number of checkboxes (or any control, for that matter) in a panel so I can cycle through them with an iteration statement... What am I missing? If this involves more code than using iteration would save, just tell me and I'll move on. Thanks in advance. :)

        J Offline
        J Offline
        J Dunlap
        wrote on last edited by
        #3

        "control arrays" per se are not supported by the VS.NET designer. However, it's easy to manually build an array containing controls that are on your form:

        CheckBox[] checkBoxes=new CheckBox[]{myCheckBox1, myCheckBox2, ...};

        If you need dynamically created control arrays that will be resized at runtime to an arbitrary size, you will need to create the checkboxes manually and add them to a list:

        List checkBoxes = new List();
        for(int i=0;i

        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