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.
 
The only way to do this is to ONLY insert the first child in the first
place.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top