TreeNode::ExpandAll Method ()
.NET Framework (current version)
Expands all the child tree nodes.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The following code example expands all the tree nodes in a TreeView control when a CheckBox is checked, and collapses the FirstNode when the CheckBox is cleared. This example requires that you have a Form with a CheckBox, and a TreeView control with a TreeNodeCollection that has several TreeNode objects (preferably with three or more levels).
void myCheckBox_CheckedChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ ) { // If the check box is checked, expand all the tree nodes. if ( myCheckBox->Checked == true ) { myTreeView->ExpandAll(); } else { // If the check box is not cheked, collapse the first tree node. myTreeView->Nodes[ 0 ]->FirstNode->Collapse(); MessageBox::Show( "The first and last node of CutomerList root node is collapsed" ); } }
.NET Framework
Available since 1.1
Available since 1.1
Show:
