how to expand a treeview

  • Thread starter Thread starter ALI-R
  • Start date Start date
A

ALI-R

I want to expand a tree view in a way that only shows the first chiled,I
don't want it to go deeper than one level??

Is here somebody who can help me?

Thanks for your time.
 
ALI-R said:
I want to expand a tree view in a way that only shows the first chiled,I
don't want it to go deeper than one level??

If you mean what I think you do, you want to expand out the first level of a
tree view so that all children of the root are visible but none of their
children are. If so this bit of code should do the trick:

myTreeView.Nodes[0].Expand();

Here "myTreeView" is a variable referring to your tree view. Note that this
assumes the tree is all collapsed before it executes; if it's not, you need
to collapse it first using myTreeView.CollapseAll(). Also, if your tree view
has multiple root nodes, and you wish to expand them all out one level,
you'll want to loop over myTreeView.Nodes. I hope this helps.
 
Back
Top