VS2010是不是没有像VB6.0那样的按键控件数组啦,查了下资料,vb6.0可以直接Command1(ID)对按键访问,VS2010是不是只能自己建立按键数组,然后赋值成员变量再对按键实现访问呀,有没有简单点的方法呀??
谢谢了
------解决方案--------------------
http://www.cnblogs.com/clso/archive/2010/11/29/1891089.html
------解决方案--------------------
http://blog.csdn.net/yuan_haijiang/article/details/7392459
------解决方案--------------------
Public Class Class1
Private Combobox1 As ComboBox
Public Property _ComboBox1() As ComboBox
Get
Return Combobox1
End Get
Set(ByVal value As ComboBox)
Combobox1 = value
End Set
End Property
Private Combobox2 As ComboBox
Public Property _ComboBox2() As ComboBox
Get
Return Combobox2
End Get
Set(ByVal value As ComboBox)
Combobox2 = value
End Set
End Property
Private Combobox3 As ComboBox
Public Property _ComboBox3() As ComboBox
Get
Return Combobox3
End Get
Set(ByVal value As ComboBox)
Combobox3 = value
End Set
End Property
Public Sub MySub()
Dim Array1 As New ArrayList
Dim Combo1 As New ComboBox
Array1.Add(Combobox1)
Array1.Add(Combobox2)
Array1.Add(Combobox3)
For index1 As Integer = 0 To Array1.Count - 1
Combo1 = Array1.Item(index1)
'循环访问每个控件,按需要自己更改写入代码
'Combo1.Text等等都能访问窗体上的每个ComboBox控件
Next
End Sub
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim myClass1 As New Class1
myClass1._ComboBox1 = Me.combobox1
myClass1._ComboBox2 = Me.ComboBox2
myClass1._ComboBox3 = Me.ComboBox3
myClass1.MySub()
End Sub
End Class
都能访问 控件数组,没有不可能的 !