Board index » delphi » Getting a TreeView Node Index Value

Getting a TreeView Node Index Value

Anyone know how to get the overall (ie treeview) index for a TreeView node.

I am wanting to collapse (in the OnExpanding or OnExpanded handler of another
node) a treeview node which has previously been expanded. I want to store the
node index of the previously expanded node so that I can close it (the Collapse
method requires the overall node index ie that obtained by allocating an
nicreasing number to each of the nodes, not just the visible ones).

The Index property of the Node parameter in the OnExpand handler gives only the
top level index. So do other attempts (Treeview.Items[i].Index).

As I load only once I have stored the overall index in the Data property of
each node, but feel that there must be a better way of doing it.

Thanks

Alan Lloyd
alangll...@aol.com

 

Re:Getting a TreeView Node Index Value


Hi Alan,

here two possible soutions:

1) In OnChange the node is passed which will receive the focus (if
allowed), but the old node is still selected, hence call
Tree.Selected.Collapse during this event
2) have a look at TTreeNT (currently version 1.0, 2.0 will come soon) which
supports the single expand feature by just setting one simple option

Ciao, Mike

AlanGLLoyd <alangll...@aol.com> schrieb im Beitrag
<1998041817453700.NAA01...@ladder03.news.aol.com>...

Quote
> Anyone know how to get the overall (ie treeview) index for a TreeView
node.

> I am wanting to collapse (in the OnExpanding or OnExpanded handler of
another
> node) a treeview node which has previously been expanded. I want to store
the
> node index of the previously expanded node so that I can close it (the
Collapse
> method requires the overall node index ie that obtained by allocating an
> nicreasing number to each of the nodes, not just the visible ones).

> The Index property of the Node parameter in the OnExpand handler gives
only the
> top level index. So do other attempts (Treeview.Items[i].Index).

> As I load only once I have stored the overall index in the Data property
of
> each node, but feel that there must be a better way of doing it.

> Thanks

> Alan Lloyd
> alangll...@aol.com

Other Threads