Control array in windows form?

Posted on 2006-05-31
Last Modified: 2010-04-16
Hi there,

I am sure this is easy but I have been using for a while and now need to use windows forms..

In vb6 i used to create like 10 checkboxes for example... named them all the same and it automatically created an array as they were all called the same but in visual studio 2005 it doesn't seem to let me do this

Am i doing osmething wrong?

Surley i don't have to create 10 checkboxes called "checkbox1", Checkbox2, checkbox3??

Thnaks in advance

Question by:ianinspain
    LVL 44

    Assisted Solution

    Hi ianinspain,

    you can create your own control array class to replicate that behaviour from VB6 it lookes like a bit more work but in the end you got more control on the details if needed later in the project

    there is a 2 part article handles the finesses of the changes in depth

    share what you know, learn what you don't
    LVL 5

    Accepted Solution

    "In Visual Basic 6.0, control arrays could be used to specify a group of controls that shared a set of events. The controls had to be of the same type, and they had to have the same name.

    In Visual Basic .NET, control arrays are no longer supported. Changes to the event model make control arrays unnecessary. Just as control arrays in Visual Basic 6.0 could share events, the event model in Visual Basic .NET allows any event handler to handle events from multiple controls. In effect, this allows you to create groups of controls of disparate types that share the same events."

    That came straight out of the MSDN Library.

    I suggestion is for you to name them all differently and have all their event method point to a common function. Use the object sender to determine which object it is. I have never done this before, but this is the way i'd probably go about it.


    LVL 96

    Expert Comment

    by:Bob Learned
    You can easily work around not having control arrays.


    Author Comment

    thanks,.... Was thinking like VB :-)

    Thanks again


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now