Control array in VB6 as we know does not exist anymore in VB.NET. Microsoft Upgrade Tools will create an array for each of the VB6 standard control array using the functionalities in Microsoft.VisualBasic.Compatibility.dll. Tsentry includes the customized control array classes for some of the TPRI standard controls (ActiveShapeArray, CmdButtonArray…). For Microsoft WinForm controls there is an option to create control array using Microsoft.VisualBasic.Compatibility class. Microsoft upgrade tool will convert the existing VB6 control arrays.
2. For the Tsentry standard controls use the included control array classes (ActiveShapeArray, CmdButtonArray…). Info |
---|
For other type of controls (user control), it is necessary to create a customized ArrayList class. |
Create a customized ArrayList classThis code should be located before the ‘Region: Windows Form Designer generated code’ There needs to be a class for each different type of array listed (e.g. ActiveShape and CmdButton) Code Block |
---|
Private Class xxxxList
Inherits ArrayList
Public Overrides Function Add(ByVal Obj As Object) As Integer
If Obj.GetType Is GetType(xxxx) Then
Return MyBase.Add(Obj)
Else
Return -1
End If
End Function
End Class |
Declare a variableThis code goes in the declarations section (generally found below the Region) The easiest way is to cut the array variable code from the ‘Friend With Events’ section and paste it into the declarations section. Then use Find/Replace from there. Code Block |
---|
Private mcolxxxx As xxxxList
OR
Private WithEvents mcolxxxx As xxxxList |
Add the controls to the listThis is located at the top inside the Region. The easiest way to do this is to copy the private declarations just added so you can see the arrays that need to be declared. Code Block |
---|
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
mcolxxxx = New xxxxList
mcolxxxx.Add(xxxx_0)
mcolxxxx.Add(xxxx_1)
…
End Sub |
Use the ArrayList as a zero based array: MessageBox.Show(Mcolxxxx(0).Name) Some of the control array classes have event(s). The events work the similar way as the control array events in VB6. Each control in the array is identified by index. |