对列表框的名称进行排序 VB.net
Sort name on a listbox VB.net
所以我的列表框中填充了文件夹中的文件。
我希望文件按升序排列,但有些文件具有相同的名称,当您在 windows 上命名具有相同名称的文件时,它就像文件名、文件名 (2)、文件名 (3)。 .. 文件名(10)...
但是在列表框中它变成了文件名 (10)、文件名 (11)、文件名 (2)、文件名 (3)... 文件名
我希望它是 windows 的样子...
我试过了,但没有结果
items = ListBox1.Items.OfType(Of Object)().ToList()
ListBox5.Items.AddRange(items.OrderBy(Function(i) i).ToArray())
试试这个:
items = ListBox1.Items
System.Array.Sort(items)
然后用 For Each
循环遍历 items
。
所以我的列表框中填充了文件夹中的文件。 我希望文件按升序排列,但有些文件具有相同的名称,当您在 windows 上命名具有相同名称的文件时,它就像文件名、文件名 (2)、文件名 (3)。 .. 文件名(10)...
但是在列表框中它变成了文件名 (10)、文件名 (11)、文件名 (2)、文件名 (3)... 文件名
我希望它是 windows 的样子...
我试过了,但没有结果
items = ListBox1.Items.OfType(Of Object)().ToList()
ListBox5.Items.AddRange(items.OrderBy(Function(i) i).ToArray())
试试这个:
items = ListBox1.Items
System.Array.Sort(items)
然后用 For Each
循环遍历 items
。