Control array in windows form?

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

Who is Participating?
"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.


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
Bob LearnedCommented:
You can easily work around not having control arrays.

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

Thanks again

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.