News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

Control Array

Started by VelMurugan, Jul 26, 2008, 08:02 PM

Previous topic - Next topic

VelMurugan

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.