Private msklistclass1 As New List(Of MaskedTextBox)
执行以下代码后,列表包含以下 MaskedTextBox 控件
For Each ctrl As Control In Me.pnlclass11.Controls
If TypeOf ctrl Is MaskedTextBox Then
msklistclass1.Add(ctrl)
End If
Next
seat112
seat212
seat312
seat412
seat512
seat612
seat122
seat222
seat322
seat422
seat522
seat622
但我想它们不是我上面显示的顺序。当我尝试按顺序为这些控件分配值时,它们不会按顺序分配。
我尝试了以下代码
For i = 0 To 11 Step 1
msklistclass1(i).Text = rno312(i)
Next
我期望的任务是
seat112 1138M0321
seat212 1138M0322
seat312 1138M0323
seat412 1138M0324
seat512 1138M0325
seat612 1138M0326
但是他们没有按这个顺序分配是否有可能对列表进行排序msklistclass1
这一行给了我以下输出 msklistclass1.Sort(Function(x, y) x.Name.CompareTo(y.Name))
seat111 1138M0321 seat121 1138M0321
seat211 1138M0323 seat221 1138M0324
seat311 1138M0325 seat321 1138M0326
seat411 1138M0326 seat421 1138M0327
seat511 1138M0328 seat521 1138M0329
seat611 1138M0330 seat621 1138M0331
但我想要
seat111 1138M0321 seat121 1138M0327
seat211 1138M0322 seat221 1138M0328
seat311 1138M0323 seat321 1138M0329
seat411 1138M0324 seat421 1138M0330
seat511 1138M0325 seat521 1138M0331
seat611 1138M0326 seat621 1138M0332