Does anyone have some code that will expand and collapse all items in a
tree? This is what I came up with for expanding, it works, but is kind
of cluttered, I am sure it can be condensed to just a few lines of code.
I also need some code for collapsing all nodes, and expanding to a
given level (for example expand to 3 would give the first three levels
of the tree, all lower nodes will be collapsed.)
Thanks for any help you can provide,
Tim Thomas
sub ExpandAll_Click
{
$TVI=$TV->SelectedItem();
$TV->Expand($TVI);
&expandchild($TVI);
}
sub expandchild
{
my($node)=$_[0];
while ($node=$TV->GetChild($node))
{
$TV->Expand($node);
my %itemdata = $TV->GetItem($node);
print "I am at: ", $itemdata{-text},"\n";
&expandsibling($node);
}
}
sub expandsibling
{
my($node)=$_[0];
while ($node=$TV->GetNextSibling($node))
{
$TV->Expand($node);
my %itemdata = $TV->GetItem($node);
print "I am at: ", $itemdata{-text},"\n";
&expandchild($node);
}
}