-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToolClass.cs
More file actions
46 lines (43 loc) · 1.35 KB
/
Copy pathToolClass.cs
File metadata and controls
46 lines (43 loc) · 1.35 KB
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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PrizeDrawTool
{
internal class ToolClass
{
//获取每个子项前面的编号
public static int GetSingleItemOrderNum(object Item)
{
return Convert.ToInt32(((string)Item).Split('.', count:2)[0]);
}
//获取每个子项除去序号的内容
public static string GetSingleItemWithoutOrder(object Item)
{
return ((string)Item).Split('\t', count: 2)[1];
}
//将ListBox按每个子项前面的编号升序排序
public static void ListBoxItemsArrangeByOrder(ref ListBox lb)
{
int cnt;
do
{
cnt = 0;
for (int i = 0; i < lb.Items.Count - 1; i++)
{
int a = ToolClass.GetSingleItemOrderNum(lb.Items[i]);
int b = ToolClass.GetSingleItemOrderNum(lb.Items[i + 1]);
if (a > b)
{
object temp = lb.Items[i];
lb.Items[i] = lb.Items[i + 1];
lb.Items[i + 1] = temp;
cnt++;
}
}
} while (cnt > 0);
}
}
}