TreeNode.ExpandAll Méthode

Définition

Développe tous les nœuds d'arbre enfants.

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

Exemples

L’exemple de code suivant développe tous les nœuds d’arborescence d’un TreeView contrôle lorsqu’un CheckBox contrôle est activé et réduit le FirstNode moment où l’objet CheckBox est effacé. Cet exemple nécessite que vous disposiez d’un Form contrôle avec un CheckBoxTreeView contrôle avec TreeNodeCollection plusieurs TreeNode objets (de préférence avec trois niveaux ou plus).

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

Remarques

La ExpandAll méthode développe tous les nœuds d’arborescence enfants affectés à la Nodes collection.

Notes

L’état d’un TreeNode est persistant. Par exemple, si le niveau suivant des nœuds enfants n’a pas été réduit précédemment, lorsque la Expand méthode est appelée, les nœuds enfants apparaissent dans leur état développé précédemment.

S’applique à

Voir aussi