我有一个 VB 表单,它在运行时动态创建 4 个组合框,分别称为 1、2、3 和 4。问题是当涉及到访问它们时,我阅读最好的方法是执行以下操作,但当然这根本不起作用,有什么想法吗?
谢谢,山姆。
Public Class Form1
Dim x As Integer
Dim y As Integer
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
x = 4
y = 0
Dim MyLocationX As Integer = 25
Dim MyLocationY As Integer = 25
Do While y <> x
Dim DropDownlist As New ComboBox
DropDownlist.Name = x
DropDownlist.Location = New Point(MyLocationX, MyLocationY)
Me.Controls.Add(DropDownlist)
y = y + 1
MyLocationY = MyLocationY + 30
Loop
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim z as Integer = 0
Do While z <> x
Dim z As New ComboBox
MsgBox(z.SelectedValue)
z++
Loop
End Sub
结束类