?
Solved

TreeView Problem

Posted on 2005-05-02
4
Medium Priority
?
207 Views
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:

[-]Root
    [-]ChildNote1
        [-]GrandChildNote1
        [-]GrandChildNote2
        [-]GrandChildNote3
    [-]ChildNote1
    [-]ChildNote3
    ....

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:

[+]Root

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?

Thanks!
0
Comment
Question by:vbwang
4 Comments
 

Expert Comment

by:komeisa
ID: 13914000


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

Author Comment

by:vbwang
ID: 13914420
I tried using this code, but it does't work.

treeView1.Clear();
...
... something code here display notes
...
treeView1.CollapseAll();
0
 
LVL 4

Accepted Solution

by:
boy8964 earned 80 total points
ID: 13914480
make sure treeView1.CollapseAll(); must be end of the display tree code. eg.

treeView1.Clear();
... show note1
..........show child note1
...........show child note2
................
... show note2
... show note3
treeView1.CollapseAll();

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

Expert Comment

by:TheAvenger
ID: 13915825
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

864 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