vb.net - Sorting List(Of MaskedTextBox) -


the list private msklistclass1 new list(of maskedtextbox) contains following maskedtextbox controls after executing following code

 each ctrl control in me.pnlclass11.controls     if typeof ctrl maskedtextbox       msklistclass1.add(ctrl)     end if  next  seat112 seat212 seat312 seat412 seat512 seat612 seat122 seat222 seat322 seat422 seat522 seat622 

but aren't in order have shown above suppose. when try assign values these controls in sequential manner don't assigned in order.

i tried following code

for = 0 11 step 1      msklistclass1(i).text = rno312(i) next 

the assignment expect

seat112  1138m0321 seat212  1138m0322 seat312  1138m0323 seat412  1138m0324 seat512  1138m0325 seat612  1138m0326 

but aren't getting assigned in order there possibility sort list msklistclass1


this line gives me following output 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 

but want

seat111  1138m0321  seat121  1138m0327 seat211  1138m0322  seat221  1138m0328 seat311  1138m0323  seat321  1138m0329 seat411  1138m0324  seat421  1138m0330 seat511  1138m0325  seat521  1138m0331 seat611  1138m0326  seat621  1138m0332 

using linq, can this:

dim listordered = m in msklistclass1 order m.text 

or if cannot use linq or not want to, this:

msklistclass1.sort(function(x, y) x.name.compareto(y.text)) 

note: if want sort different property of maskedtextbox, change text whatever property name is, name instance.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -