为了对下的兼容VB.Net事实上是支持VB6的控件数组的,只是使用方法没有VB6那样方便,他对应的控件数组类位于Microsoft.VisualBasic.Compatibility.VB6命名空间下
声明方法:
Public WithEvents Command1 As Microsoft.VisualBasic.Compatibility.VB6.ButtonArray
Me.Command1 = New Microsoft.VisualBasic.Compatibility.VB6.ButtonArray(components)
往控件数组里面添加控件
Public WithEvents _Command1_1 As System.Windows.Forms.Button
Public WithEvents _Command1_0 As System.Windows.Forms.Button
Me._Command1_1 = New System.Windows.Forms.Button
Me._Command1_0 = New System.Windows.Forms.Button
Me.Command1.SetIndex(_Command1_1, CType(1, Short))
Me.Command1.SetIndex(_Command1_0, CType(0, Short))
当然你也可以把该命名空间下的类放到工具箱里,然后通过拖放操作完成控件数组的添加