TreeNode.ExpandAll Método

Definición

Expande todos los nodos de árbol secundarios.Expands all the child tree nodes.

public:
 void ExpandAll();
public void ExpandAll ();
member this.ExpandAll : unit -> unit
Public Sub ExpandAll ()

Ejemplos

En el TreeView ejemplo de código siguiente CheckBox se expanden todos los nodos de árbol de un control cuando se comprueba y se FirstNode CheckBox contrae cuando se borra.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. Este ejemplo requiere que Form tenga un CheckBoxcon y un TreeView control con un TreeNodeCollection que tenga varios TreeNode objetos (preferiblemente con tres o más niveles).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 checked, collapse the first tree node.
      myTreeView->Nodes[ 0 ]->FirstNode->Collapse();
      MessageBox::Show( "The first node of CustomerList root node is collapsed" );
   }
}
private 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 checked, collapse the first tree node.
      myTreeView.Nodes[0].FirstNode.Collapse();
      MessageBox.Show("The first node of CustomerList root node is collapsed");
   }
}
Private Sub myCheckBox_CheckedChanged(ByVal sender As Object, _
   ByVal e As System.EventArgs) Handles myCheckBox.CheckedChanged
   ' If the check box is checked, expand all the tree nodes.
   If myCheckBox.Checked = True Then
      myTreeView.ExpandAll()
   Else
      ' If the check box is not checked, collapse the first tree node.
      myTreeView.Nodes(0).FirstNode.Collapse()
      MessageBox.Show("The first node of CustomerList root node is collapsed")
   End If
End Sub

Comentarios

El ExpandAll método expande todos los nodos de árbol secundarios asignados a Nodes la colección.The ExpandAll method expands all the child tree nodes assigned to the Nodes collection.

Nota

El estado de un TreeNode se conserva.The state of a TreeNode is persisted. Por ejemplo, si el siguiente nivel de nodos secundarios no se contrajo previamente, cuando Expand se llama al método, los nodos secundarios aparecen en el estado expandido anteriormente.For example, if the next level of child nodes was not collapsed previously, when the Expand method is called, the child nodes appear in their previously expanded state.

Se aplica a

Consulte también: