TreeNode.ExpandAll Metodo

Definizione

Espande tutti i nodi figli della struttura ad albero.

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

Esempio

Nell'esempio di codice seguente vengono espansi tutti i nodi dell'albero in un TreeView controllo quando viene controllato un CheckBox oggetto e viene compresso FirstNode quando l'oggetto CheckBox viene cancellato. In questo esempio è necessario disporre Form di un oggetto con e un TreeView CheckBoxcontrollo con un TreeNodeCollection oggetto con diversi TreeNode oggetti (preferibilmente con tre o più livelli).

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

Commenti

Il ExpandAll metodo espande tutti i nodi dell'albero figlio assegnati alla Nodes raccolta.

Nota

Lo stato di un TreeNode oggetto viene mantenuto. Ad esempio, se il livello successivo di nodi figlio non è stato compresso in precedenza, quando il metodo viene chiamato, i Expand nodi figlio vengono visualizzati nello stato espanso in precedenza.

Si applica a

Vedi anche