TreeNode.FullPath プロパティ
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ルート ツリー ノードから現在のツリー ノードまでのパスを取得します。
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 に含まれていません。
次のコード例では、 の プロパティをPathSeparatorTreeView設定し、 の にTreeNodeCollection含まれる子ツリー ノードの数をSelectedNode表示します。 ツリー ビュー コントロールのツリー ノードの合計に対する子ツリー ノードの割合も表示されます。 この例では、 を持Formつ Buttonと、TreeView複数TreeNodeのオブジェクト (できれば 3 つ以上のレベルを持つ) を持つ コントロール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" になります。
製品 | バージョン |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。