所以我编写了一个代码来重新排序列表视图的列(实际上只是 -=1 和 +=1 是所选列表视图列的显示索引。但是当我移动列时,子项会保留。它们不会移动。我想与列一起移动的相应子项。
main.listView1.Columns[listBox1.SelectedIndex].DisplayIndex += 1;
listBox1.Select();
listBox1_SelectedIndexChanged(sender, e); //the code for moving the column to the right
main.listView1.Columns[listBox1.SelectedIndex].DisplayIndex -= 1;
listBox1.Select();
listBox1_SelectedIndexChanged(sender, e); //the code for moving the column to the left