TreeView.ExpandAll Metoda

Definice

Rozbalí všechny uzly stromu.

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

Příklady

Následující příklad kódu rozbalí všechny uzly stromu v ovládacím prvku, když je zaškrtnutoTreeView, a sbalíCheckBox, když FirstNode je vymazání.CheckBox Tento příklad vyžaduje, abyste měli s objektem FormCheckBoxa TreeView ovládací prvek s TreeNodeCollection několika TreeNode objekty (pokud možno se třemi nebo více úrovněmi).

void myCheckBox_CheckedChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{

   // If the check box is checked, expand all the tree nodes.
   if ( myCheckBox->Checked )
   {
      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)
   {
      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

Poznámky

Metoda ExpandAll rozbalí všechny TreeNode objekty, které zahrnují všechny podřízené uzly stromu, které jsou v ovládacím TreeView prvku.

Note

Stav trvalých TreeNode hodnot. Předpokládejme například, že voláte metodu ExpandAll a pak jsou jednotlivé uzly kořenového stromu sbalené. Uzly podřízeného stromu nebyly sbalené a při opětovném rozbalení uzlů kořenového stromu se zobrazí v dříve rozbaleném stavu. CollapseAll Voláním metody zajistíte, že se všechny uzly stromu zobrazí ve sbaleném stavu.

Platí pro

Viz také