摘要:讓 Treeview 能夠Click新節點時把舊的節點全部Collpse
bool Block = false;
protected void TreeView1_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
{
if (Block == true) // stop recursive re-entrancy
return;
Block = true;
TreeView1.CollapseAll();
// expand current node and all parent nodes
TreeNode Node = e.Node;
while (Node != null)
{
Node.Expand();
Node = Node.Parent;
}
Block = false;
}