ツリー ノードのパスで使用する区切り記号を取得または設定します。
名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
'宣言
Public Property PathSeparator As String
'使用
Dim instance As TreeView
Dim value As String
value = instance.PathSeparator
instance.PathSeparator = value
public string PathSeparator { get; set; }
public:
property String^ PathSeparator {
String^ get ();
void set (String^ value);
}
/** @property */
public String get_PathSeparator ()
/** @property */
public void set_PathSeparator (String value)
public function get PathSeparator () : String
public function set PathSeparator (value : String)
プロパティ値
ツリー ノードの TreeNode.FullPath プロパティで使用する区切り記号。既定値は、円記号 (\) です。
解説
ツリー ノードのパスは、PathSeparator 区切り記号で区切られた一連のツリー ノード ラベルで構成されます。パスに含まれるラベルは、ルート ツリー ノードから目的のツリー ノードまでのラベルです。
使用例
TreeView の PathSeparator プロパティを設定し、SelectedNode の TreeNodeCollection に含まれている子ツリー ノードの数を表示するコード例を次に示します。ツリー ビュー コントロール内のすべてのツリー ノードに対する子ツリー ノードの割合も表示されます。この例は、Form 上に、Button と TreeView コントロール が配置され、その TreeView に、複数の TreeNode オブジェクト (3 レベル以上を推奨) を持つ TreeNodeCollection が設定されていることを前提にしています。
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
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
.NET Compact Framework
サポート対象 : 2.0、1.0
参照
関連項目
TreeView クラス
TreeView メンバ
System.Windows.Forms 名前空間
TreeNode.FullPath プロパティ