Export (0) Print
Expand All

TreeNode.FullPath Property

Gets the path from the root tree node to the current tree node.

[Visual Basic]
Public ReadOnly Property FullPath As String
[C#]
public string FullPath {get;}
[C++]
public: __property String* get_FullPath();
[JScript]
public function get FullPath() : String;

Property Value

The path from the root tree node to the current tree node.

Remarks

The path consists of the labels of all the tree nodes that must be navigated to get to this tree node, starting at the root tree node. The node labels are separated by the delimiter character specified in the PathSeparator property of the TreeView control that contains this node. For example, if the delimiter character of the tree view control named "Location" is set to the backslash character, (\), the FullPath property value is "Country\Region\State".

Example

[Visual Basic, C#, C++] The following example set the PathSeparator proprety of a TreeView and displays the number of child tree nodes contained in the TreeNodeCollection of the SelectedNode. The percentage of child tree node to total tree nodes in the tree view control is also displayed. This example assumes you have a Form with a Button, and a TreeView control with a TreeNodeCollection that has several TreeNode objects (preferably with three or more levels).

[Visual Basic] 
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

[C#] 
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.");
}

[C++] 
private:
    void myButton_Click(Object* /*sender*/, System::EventArgs* /*e*/) {
        // Set the tre view's PathSeparator property.
        myTreeView->PathSeparator = S".";

        // 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(S"The '", myTreeView->SelectedNode->FullPath,
            S"' node has ", __box(myNodeCount), S" child nodes.\nThat is ",
            String::Format(S"{0:###.##}", __box(myChildPercentage)),
            S"% of the total tree nodes in the tree view control."));
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

TreeNode Class | TreeNode Members | System.Windows.Forms Namespace | PathSeparator

Show:
© 2014 Microsoft