TreeView Problem

Posted on 2005-05-02
Last Modified: 2010-04-16
Language: C#
App Type: Windows application

this is very simple question if you knew it ...

I have a treeView on a windows form. the tree is somethting like this:


when i load the form, the tree is like this -- show all child notes, grand child notes ... what I want is that when I load the form, show a "closed" tree, like this:


only when user click the [+] and then it displays the child notes ...

What preperty i need set to the treeview in order to get a "closed" tree?

Question by:vbwang

    Expert Comment


     The treeview has a function called CollapseAll() that collapses all the nodes. You could call it in your InitializeComponent procedure

    Author Comment

    I tried using this code, but it does't work.

    ... something code here display notes
    LVL 4

    Accepted Solution

    make sure treeView1.CollapseAll(); must be end of the display tree code. eg.

    ... show note1 child note1 child note2
    ... show note2
    ... show note3

    the code treeView1.CollapseAll() must at end of the display tree code!
    LVL 20

    Expert Comment

    Or you can call Collapse() for every node you want to close, e.g. only for the root node. Again: after adding its child nodes

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now