Frage

I've got a dataTreeListView which has got afew column headers as added to it as follows:

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;

The list itself has got 7 properties (inclusive of Id and ParentId).

What I'm trying to achieve is that, upon selectedIndex change of a combo box, the column header will change position.

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

What I got now is view (type1) is working correctly, but after switching to view type2, the expandable column is still at oCol1 instead of oCol2. It seems that I could not switch the primary column.

Any help for this?

War es hilfreich?

Lösung

If you just want to change the ordering, change the DisplayIndex property on each column.

If you want to hide/show columns (as well as reordering them), you change the contents of AllColumns and then call RebuildColumns(). See this FAQ

If you want to swap between various column layouts, you can use SaveState() and RestoreState() See this recipe

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top