【发布时间】:2009-11-25 14:57:26
【问题描述】:
我的应用中有两个 ListView,它们的列集合最初是相同的。当用户对一个列重新排序时,我希望另一个列重新排序。
我在其中一个视图的 ColumnReordered 事件上有以下事件处理程序,在另一个上有相应的处理程序:
private volatile bool reorderingColumns;
private void listView1_ColumnReordered(object sender, ColumnReorderedEventArgs e)
{
// Prevent reentry - is this necessary?
if (reorderingColumns)
return;
try
{
reorderingColumns = true;
// copy display indices to the other listView
for (int i = 0; i < columnInfo.Count; i++)
{
listView2.Columns[i].DisplayIndex = listView1.Columns[i].DisplayIndex;
}
}
finally
{
reorderingColumns = false;
}
}
但是,第二个列表视图中的列顺序保持不变。我需要做什么才能让第二个列表视图以新顺序重绘其列?
【问题讨论】: