Metodo TreeNode.ExpandAll (System.Windows.Forms)

Cambia visualizzazione:
ScriptFree
Riferimento a .NET Framework
Metodo TreeNode.ExpandAll

Espande tutti i nodi figli della struttura.

Spazio dei nomi: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Sintassi

Visual Basic - (Dichiarazione)
Public Sub ExpandAll
Visual Basic (Utilizzo)
Dim instance As TreeNode

instance.ExpandAll
C#
public void ExpandAll ()
C++
public:
void ExpandAll ()
J#
public void ExpandAll ()
JScript
public function ExpandAll ()
Note

Il metodo ExpandAll espande tutti i nodi figli della struttura assegnati all'insieme Nodes.

NotaNota

Lo stato di un oggetto TreeNode viene conservato. Se ad esempio il livello successivo dei nodi figli non era stato precedentemente compresso, quando viene chiamato il metodo Expand, i nodi figli vengono visualizzati nello stato espanso.

Esempio

Nell'esempio di codice riportato di seguito vengono espansi tutti i nodi della struttura di un controllo TreeView quando un controllo CheckBox è selezionato e viene compressa la proprietà FirstNode quando il controllo CheckBox è deselezionato. Per eseguire questo esempio è necessario disporre di un oggetto Form con un oggetto CheckBox e di un controllo TreeView con un insieme TreeNodeCollection contenente numerosi oggetti TreeNode preferibilmente in tre o più livelli.

Visual Basic
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 cheked, collapse the first tree node.
      myTreeView.Nodes(0).FirstNode.Collapse()
      MessageBox.Show("The first and last node of CutomerList root node is collapsed")
   End If
End Sub

C#
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 cheked, collapse the first tree node.
      myTreeView.Nodes[0].FirstNode.Collapse();
      MessageBox.Show("The first and last  node of CutomerList root node is collapsed");
   }
}

C++
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" );
   }
}

J#
private void myCheckBox_CheckedChanged(Object sender, System.EventArgs e)
{
    // If the check box is checked, expand all the tree nodes.
    if (myCheckBox.get_Checked() == true) { 
        myTreeView.ExpandAll();
    }
    else {
        // If the check box is not cheked, collapse the first tree node.
        myTreeView.get_Nodes().get_Item(0).get_FirstNode().Collapse();
        MessageBox.Show("The first and last  node of CutomerList root "
            + "node is collapsed");
    }
} //myCheckBox_CheckedChanged

Piattaforme

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile per Pocket PC, Windows Mobile per Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema.

Informazioni sulla versione

.NET Framework

Supportato in: 2.0 1.1 1.0

.NET Compact Framework

Supportato in: 2.0 1.0
Vedere anche