实现如下图所示的功能:
代码如下所示: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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68/// <summary>
/// Move one or more items from left to right
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MoveToRight_Click(object sender, EventArgs e)
{
int ItemCount = AllTestCase.SelectedItems.Count;
if (ItemCount > 0)
{
for (int i = 0; i < ItemCount; i++)
{
SelectedTestCase.Items.Add(AllTestCase.SelectedItem);
AllTestCase.Items.Remove(AllTestCase.SelectedItem);
}
}
else
{
MessageBox.Show("Please select one or more items.");
}
}
/// <summary>
/// Move all items from left to right
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MoveAllToRight_Click(object sender, EventArgs e)
{
SelectedTestCase.Items.AddRange(AllTestCase.Items);
AllTestCase.Items.Clear();
}
/// <summary>
/// Move one or more items from right to left
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MoveToLeft_Click(object sender, EventArgs e)
{
int ItemCount = SelectedTestCase.SelectedItems.Count;
if (ItemCount > 0)
{
for (int i = 0; i < ItemCount; i++)
{
AllTestCase.Items.Add(SelectedTestCase.SelectedItem);
SelectedTestCase.Items.Remove(SelectedTestCase.SelectedItem);
}
}
else
{
MessageBox.Show("Please select one or more items.");
}
}
/// <summary>
/// Move all items from right to left
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MoveAllToLeft_Click(object sender, EventArgs e)
{
AllTestCase.Items.AddRange(SelectedTestCase.Items);
SelectedTestCase.Items.Clear();
}