2014-01-29 66 views
0

我有一个dataTreeListView作为添加到它如下这已经得到了当场打死列标题:ObjectListView重新排序列

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的主要栏目。

对此有何帮助?

+0

的2型视图,然后再oCol1(可扩展)定义oCol2。根据你的问题,这看起来像一个预期的输出。除非我错过任何东西。 –

+0

嗨theghostofc,我试图做这样的事情。 dataTreeListView.AllColumns.Clear(); oCol2.IsVisible = true; dataTreeListView.AllColumns.AddRange(new OLVColumn [] {oCol2,oCol1,oCol3,oCol4,oCol5,}); 结果仍然是一样的,第一列的oCol1 – user3167398

回答

0

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

如果要隐藏/显示列(以及重新排列它们),请更改AllColumns的内容,然后致电RebuildColumns()。见this FAQ

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

+0

您好Grammarian,我已经使用另一种方法来处理我的数据显示,谢谢! – user3167398