1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | Dim items = (From item In ListBox1.Items Order By CInt(item) Select item).ToArray 'Dim items = (From item In ListBox1.Items Let parts = item.ToString.Split(New String() {"."}, StringSplitOptions.None) Order By CInt(parts(0)) Select item).ToArray '如有文字的話 ListBox1.Items.Clear() ListBox1.Items.AddRange(items) ------------------------------------------------------------ 'sort by first number Dim items = (From item In ListBox1.Items _ Let parts = item.ToString.Split(New String() {" - ("}, StringSplitOptions.None) _ Order By CInt(parts(0)) _ Select item).ToArray ListBox1.Items.Clear() ListBox1.Items.AddRange(items) 'sort by first number, then by second number Dim items = (From item In ListBox1.Items _ Let parts = item.ToString.Split(New String() {" - ("}, StringSplitOptions.None) _ Order By CInt(parts(0)), CInt(parts(1).TrimEnd(")"c)) _ Select item).ToArray ListBox1.Items.Clear() ListBox1.Items.AddRange(items) |
2020年5月17日 星期日
vb.net listbox 裡的數字重新排列 (sort) [Listbox sort number]
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言