共用方式為


TreeNode.FullPath 屬性

定義

取得從根樹狀節點通往目前樹狀節點的路徑。

public:
 property System::String ^ FullPath { System::String ^ get(); };
public string FullPath { get; }
[System.ComponentModel.Browsable(false)]
public string FullPath { get; }
member this.FullPath : string
[<System.ComponentModel.Browsable(false)>]
member this.FullPath : string
Public ReadOnly Property FullPath As String

屬性值

從根樹狀節點通往目前樹狀節點的路徑。

屬性

例外狀況

節點未包含在 TreeView 中。

範例

下列程式碼範例會 PathSeparator 設定 的 TreeView 屬性,並顯示 包含在 TreeNodeCollectionSelectedNode 中的子樹狀節點數目。 樹狀檢視控制項中子樹狀節點與樹狀節點總數的百分比也會顯示。 此範例需要您具有 FormButton ,以及具有數 TreeNodeTreeView 物件的 控制項 TreeNodeCollection (,最好是具有三個以上的層級) 。

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

   // Set the tree 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 tree 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.");
}
Private Sub myButton_Click(ByVal sender As Object, _
  ByVal e As System.EventArgs) Handles myButton.Click
   ' Set the tree 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

備註

路徑包含必須巡覽以到達此樹狀節點的所有樹狀節點標籤,從根樹狀節點開始。 節點標籤會以包含這個節點之 TreeView 控制項的 屬性中指定的 PathSeparator 分隔符號分隔。 例如,如果名為 「Location」 的樹狀檢視控制項分隔符號設定為反斜線字元, (\) , FullPath 則屬性值為 「Country\Region\State」。

適用於

另請參閱