Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Visual Basic (Microsoft) VB.NET FAQ


Control Arrays and .NET by PGoRule
Posted: 3 Oct 06

Control Array:

It's a group of controls those share the set of events. The members of this group are of same type and of same name. You can create a control array either by copy and paste of controls on form. This paste option shows a dialog whether the user wants to create a control array or not. If the user says 'Yes', that will create a control array for those controls which can be distinguished by their Index. If the user says 'No', then each control will be treated as seperate control. The second way of creating a control array can be, just drop the controls of same type on form, change the name of other controls identical to first control, give proper index for all controls. Whenever any control in the array is clicked, the event is  triggered by VB each time and the control which caused the trigger can be easily checked by checking the Index parameter.

In Visual Basic .NET the control arrays are not supported. In VB6, the events were tied to specific object those were having their own event handling code. So if there are two different controls on form then both of those controls can have their own 'Click' event handlers. In VB.NET, the events are tied together to event handlers via delegates, which allows you to create a single event handler for multile objects. Also the names and behavior of some events for various objects are different. These all changes to event model makes the control arrays unnecessory. Just as control arrays in VB6 could share events, the event model in VB.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. Another feature of Visual Basic 6.0 control arrays was the ability to reference a control by its Index property. Although Visual Basic .NET controls do not have an Index property, you can duplicate the functionality using another common property such as the TabIndex or Tag property. When controls are in an array, they also share the same event procedures.

For more details on Control Array:

What Happened to Control Arrays!!! - Part 1
What Happened to Control Arrays!!! - Part 2
Creating Control Arrays in Visual Basic .NET and Visual C# .NET

Hope the above links may help you getting more in Control Arrays.


Back to Visual Basic (Microsoft) VB.NET FAQ Index
Back to Visual Basic (Microsoft) VB.NET Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close