【问题标题】:ObjectListView Column ReorderingObjectListView 列重新排序
【发布时间】:2014-02-05 10:54:51
【问题描述】:

我有一个dataTreeListView,其中添加了几个列标题,如下所示:

oCol2.IsVisible = false;
dataTreeListView.AllColumns.AddRange(new OLVColumn[] { oCol1, oCol2, oCol3, oCol4, oCol5});

dataTreeListView.KeyAspectName = id;
dataTreeListView.ParentKeyAspectName = ParentId;
dataTreeListView.DataSource = list;
dataTreeListView.RootKeyValue = 0;

列表本身有 7 个属性(包括 IdParentId)。

我想要实现的是,在 selectedIndex 更改组合框时,列标题将更改位置。

From View (type1) (oCol2.IsVisible = false):
oCol1 (expandable) | oCol2 (hidden) | oCol3 |   oCol4 | oCol5

To View (type2) (oCol2.IsVisible = true):
oCol2 | oCol1 (expandable) | oCol3 | oCol4 | oCol5

我现在得到的是视图 (type1) 工作正常,但切换到视图 type2 后,可扩展列仍然位于 oCol1 而不是 oCol2。看来我不能switch主列。

对此有什么帮助吗?

【问题讨论】:

  • type2 视图首先定义 oCol2,然后定义 oCol1(可扩展)。根据您的问题,这看起来像是预期的输出。除非我错过了什么。
  • 嗨 theghostofc,我尝试过这样做。 dataTreeListView.AllColumns.Clear(); oCol2.IsVisible = true; dataTreeListView.AllColumns.AddRange (new OLVColumn[] { oCol2, oCol1, oCol3, oCol4, oCol5, });结果还是一样,第一列的oCol1

标签: c# objectlistview


【解决方案1】:

如果您只想更改排序,请更改每列的DisplayIndex 属性。

如果您想隐藏/显示列(以及重新排序),您可以更改AllColumns 的内容,然后调用RebuildColumns()。见this FAQ

如果你想在各种列布局之间交换,可以使用SaveState()RestoreState()this recipe

【讨论】:

  • 您好 Grammarian,我已经使用另一种方法来处理我的数据显示,谢谢!
猜你喜欢
  • 1970-01-01
  • 2015-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-18
  • 1970-01-01
  • 2012-11-18
相关资源
最近更新 更多