Menu

TreeListView Expand some Nodes

Help
2014-07-26
2016-12-19
  • SwordMaster

    SwordMaster - 2014-07-26

    Hello,

    Can someone help me? i want to expand some nodes in the TreeListView. (Not all nodes!)

    For Example: Some Nodes should have AutoExpand. (e.g. the first 2 Levels)

    I couldn't find a way. i only found the method ExpandAll().
    But this is to much for me. :-(.

    i searched in the TreeListView, OLVListItem classes. But i didn't find something.
    or is it possible the the my object modell can decide which nodes should expand?

    I hope someone can give me an hint.

    Regards
    Stefan

     
  • Phillip Piper

    Phillip Piper - 2014-08-05

    Just call Expand() for each model in turn.

     
  • Michael

    Michael - 2016-12-19

    Make a List<> of the model objects you wish to have in an expanded state and set the list to the TreeListView's ExpandedObjects property...

    private void ExpandFirst2Levels() {
        var expanded = new List<MyObject>();
        foreach(MyObject o in listOfObjects) {
            if(o.Level < 2) expanded.Add(o);
        }
        MyTreeListView.ExpandedObjects = expanded;
    }
    

    If you wish to keep objects expanded that already were, previous to the call, just replace...

        var expanded = new List<MyObjects>();
    

    ...with...

        var expanded = MyTreeListView.ExpandedObjects;
    
     

    Last edit: Michael 2016-12-19

Log in to post a comment.