列表Private msklistclass1 As New List(Of MaskedTextBox)
包含以下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
「他們沒有按順序分配」 - 是的。它們按照與'rno312'相同的順序分配。 – nmclean
'rno312'是字符串列表,它在分配之前被排序 –
如果'rno312'被排序,那麼'msklistclass1'也是如此。你有什麼問題? – nmclean