TreeView.PathSeparator Property
Assembly: System.Windows.Forms (in system.windows.forms.dll)
/** @property */ public String get_PathSeparator () /** @property */ public void set_PathSeparator (String value)
public function get PathSeparator () : String public function set PathSeparator (value : String)
Property Value
The delimiter string that the tree node TreeNode.FullPath property uses. The default is the backslash character (\).The following code example sets the PathSeparator property 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 requires that 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).
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."); }
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
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.