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. Control Arrays

Control Arrays

Scheduled Pinned Locked Moved C#
csharpquestion
5 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    How do you implement control arrays in C#?

    L 1 Reply Last reply
    0
    • L Lost User

      How do you implement control arrays in C#?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      And why is everyone so against them!!! I mean, every time I turn around, MS is throwing them out: Can't do them in VB.Net, couldn't do it (could hack it) in MFC, etc. What is the deal!!!

      D 1 Reply Last reply
      0
      • L Lost User

        And why is everyone so against them!!! I mean, every time I turn around, MS is throwing them out: Can't do them in VB.Net, couldn't do it (could hack it) in MFC, etc. What is the deal!!!

        D Offline
        D Offline
        David Wengier
        wrote on last edited by
        #3

        You dont need control arrays. In VB, they gave you the ability to write one event handler for a whole bunch of controls. With AddHandler in VB.NET (or using the += operator for events in C#) you can acheive the same thing, with the extra advantage that they dont even have to be the same type of controls, or the same events. The other thing it let you do in VB was to add controls at run time. In VB.NET and C# this is now even easier. Control arrays were an ugly way to do what .NET has made fairly elegant. -- David Wengier TAC ad gone wrong: "Don't fool yourself, you're a bloody idiot." Sonork ID: 100.14177 - Ch00k

        L 1 Reply Last reply
        0
        • L Lost User

          But I want to be able to use loops when I'm working with my controls...drawing them for instance... An event isn't going to help me do that!

          J Offline
          J Offline
          James T Johnson
          wrote on last edited by
          #4

          Thats what collections are good for :) foreach( MyControl c in MyControlCollection ) {   // use c } James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

          1 Reply Last reply
          0
          • D David Wengier

            You dont need control arrays. In VB, they gave you the ability to write one event handler for a whole bunch of controls. With AddHandler in VB.NET (or using the += operator for events in C#) you can acheive the same thing, with the extra advantage that they dont even have to be the same type of controls, or the same events. The other thing it let you do in VB was to add controls at run time. In VB.NET and C# this is now even easier. Control arrays were an ugly way to do what .NET has made fairly elegant. -- David Wengier TAC ad gone wrong: "Don't fool yourself, you're a bloody idiot." Sonork ID: 100.14177 - Ch00k

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            But I want to be able to use loops when I'm working with my controls...drawing them for instance... An event isn't going to help me do that!

            J 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