Freigeben über


TreeNode.FullPath-Eigenschaft

Ruft den Pfad vom Stammknoten zum aktuellen Strukturknoten ab.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public ReadOnly Property FullPath As String
'Usage
Dim instance As TreeNode
Dim value As String

value = instance.FullPath
public string FullPath { get; }
public:
property String^ FullPath {
    String^ get ();
}
/** @property */
public String get_FullPath ()
public function get FullPath () : String

Eigenschaftenwert

Der Pfad vom Stammknoten zum aktuellen Strukturknoten.

Ausnahmen

Ausnahmetyp Bedingung

InvalidOperationException

Der Knoten befindet sich nicht in einer TreeView.

Hinweise

Der Pfad besteht aus den Bezeichnungen aller Strukturknoten, die bis zu diesem Strukturknoten durchlaufen werden müssen, wobei der Anfangspunkt der Stammknoten ist. Die Knotenbezeichnungen werden durch das Trennzeichen abgegrenzt, das in der PathSeparator-Eigenschaft des TreeView-Steuerelements enthalten ist, das diesen Knoten enthält. Wenn das Trennzeichen eines Strukturansicht-Steuerelements mit der Bezeichnung "Location" auf einen umgekehrten Schrägstrich (\) festgelegt ist, lautet der FullPath-Eigenschaftenwert "Country\Region\State".

Beispiel

Im folgenden Codebeispiel wird die PathSeparator-Eigenschaft einer TreeView festgelegt, und die Anzahl der untergeordneten Strukturknoten in der TreeNodeCollection des SelectedNode wird angezeigt. Der Prozentanteil der untergeordneten Strukturknoten an der Gesamtzahl der Strukturknoten im Strukturansicht-Steuerelement wird ebenfalls angezeigt. Für dieses Beispiel ist es erforderlich, dass ein Form mit einer Button sowie ein TreeView-Steuerelement mit einer TreeNodeCollection mit mehreren TreeNode-Objekten (vorzugsweise mit drei oder vier Ebenen) vorhanden sind.

Private Sub myButton_Click(ByVal sender As Object, _
  ByVal e As System.EventArgs) Handles myButton.Click
   ' Set the tre view's PathSeparator property.
   myTreeView.PathSeparator = "."

   ' Get the count of the child tree nodes contained in the SelectedNode.
   Dim myNodeCount As Integer = myTreeView.SelectedNode.GetNodeCount(True)
   Dim myChildPercentage As Decimal = CDec(myNodeCount) / _
      CDec(myTreeView.GetNodeCount(True)) * 100

   ' Display the tree node path and the number of child nodes it and the tree view have.
   MessageBox.Show(("The '" + myTreeView.SelectedNode.FullPath + "' node has " _
      + myNodeCount.ToString() + " child nodes." + Microsoft.VisualBasic.ControlChars.Lf _
      + "That is " + String.Format("{0:###.##}", myChildPercentage) _
      + "% of the total tree nodes in the tree view control."))
End Sub
private void myButton_Click(object sender, System.EventArgs e)
{
   // Set the tre view's PathSeparator property.
   myTreeView.PathSeparator = ".";

   // Get the count of the child tree nodes contained in the SelectedNode.
   int myNodeCount = myTreeView.SelectedNode.GetNodeCount(true);
   decimal myChildPercentage = ((decimal)myNodeCount/
     (decimal)myTreeView.GetNodeCount(true)) * 100;

   // Display the tree node path and the number of child nodes it and the tree view have.
   MessageBox.Show("The '" + myTreeView.SelectedNode.FullPath + "' node has " 
     + myNodeCount.ToString() + " child nodes.\nThat is " 
     + string.Format("{0:###.##}", myChildPercentage) 
     + "% of the total tree nodes in the tree view control.");
}
void myButton_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   
   // Set the tre view's PathSeparator property.
   myTreeView->PathSeparator = ".";
   
   // Get the count of the child tree nodes contained in the SelectedNode.
   int myNodeCount = myTreeView->SelectedNode->GetNodeCount( true );
   Decimal myChildPercentage = ((Decimal)myNodeCount / (Decimal)myTreeView->GetNodeCount( true )) * 100;
   
   // Display the tree node path and the number of child nodes it and the tree view have.
   MessageBox::Show( String::Concat( "The '", myTreeView->SelectedNode->FullPath, "' node has ", myNodeCount, " child nodes.\nThat is ", String::Format( "{0:###.##}", myChildPercentage ), "% of the total tree nodes in the tree view control." ) );
}
private void myButton_Click(Object sender, System.EventArgs e)
{
    // Set the tre view's PathSeparator property.
    myTreeView.set_PathSeparator(".");
    // Get the count of the child tree nodes contained in the SelectedNode.
    int myNodeCount = myTreeView.get_SelectedNode().GetNodeCount(true);
    System.Decimal myChildPercentage =
        Decimal.Multiply(Decimal.Divide(new Decimal(myNodeCount),
        new Decimal(myTreeView.GetNodeCount(true))), new Decimal(100));
    // Display the tree node path and the number of child nodes it and the
    // tree view have.
    MessageBox.Show("The '" + myTreeView.get_SelectedNode().get_FullPath()
        + "' node has " + ((Int32)myNodeCount).ToString()
        + " child nodes.\nThat is " + String.Format("{0:###.##}",
        myChildPercentage)
        + "% of the total tree nodes in the tree view control.");
} //myButton_Click

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

TreeNode-Klasse
TreeNode-Member
System.Windows.Forms-Namespace
PathSeparator