我尝试了以下代码将MaskedTextBox
from 中的控件列表分配给 list msklist
。但是即使执行了我下面显示的代码,索引值仍然是 0。我的表单中有 30 个MaskedTextBox
控件。
Private msklist As New List(Of MaskedTextBox)
Private msk() As MaskedTextBox
For Each ctrl In Me.Controls
If TypeOf ctrl Is MaskedTextBox Then
msklist.Add(ctrl)
End If
Next
MsgBox(msklist.Count)
ReDim msk(msklist.Count - 1)
msk = msklist.ToArray
For i = 0 To 29 Step 1
query = "SELECT * FROM allotment_table WHERE seat=@seat"
cmd.Parameters.AddWithValue("@seat", seat1(i))
cmd = New SqlCommand(query, con)
con.Open()
re = cmd.ExecuteReader
re.Read()
msk(i).Text = re("regno")
con.Close()
Next
我希望Text
使用带有数组的for循环将文本分配给控件的属性msk
我需要一些建议