Clif Gay writes, "There are 37 array controls in .NET 2.0, and 20 in .NET 1.x. These include controls like: CheckBoxArray, CheckedListBoxArray, ColorDialogArray, ComboBoxArray, DirListBoxArray, DriveListBoxArray, FileListBoxArray, etc."
Step 1 is to add a reference to Microsoft.VisualBasic.Compatibility to your project and then add an array component to the Toolbox. Right-click the project and select Add Reference ... To add the control you're interested in (for example, LabelArray) to the Toolbox, right-click the Toolbox and select Choose Items ... or select Choose Toolbox Items ... from the Tools menu, and check LabelArray.
The critical step is to add a line of code to Form1.Designer.vb. Clif suggests adding it in the initialization code for the Label:
Me.myLabelArray.SetIndex(Me.myLabel, CType(0, Short))
This assumes that you have named the LabelArray component myLabelArray and the starting Label myLabel. Note that 0 is the value of the index.
Then close the Form designer (this saves the code - VB.NET 2003 will confirm the save) and open it again. Notice that in the properties for the label, there's a new property now:
Index on myLabelArray 0
This is enough initialization to allow the same code used in VB 6 to be reused here. (But keep in mind that pixels are much larger than twips in incrementing the Top property.)
Before you jump on board and start using these ideas wholesale, keep this statement from Microsoft in mind:
The compatibility classes should not be used for new development. The Microsoft.VisualBasic.Compatibility namespace adds a layer of complexity to your Visual Basic .NET application and introduces some minimal performance costs that could be eliminated by recoding portions of the application. In addition, the Compatibility namespace often contains many classes that wrap COM objects, and ... depending on COM objects is not as optimal as a pure managed implementation.
Fortunately, you never have to use control arrays in VB.NET and Clif shows this very clearly on the next page ....

