Freigeben über


TreeView.PathSeparator-Eigenschaft

Ruft die für den Pfad des Strukturknotens verwendete Trennzeichenfolge ab oder legt diese fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Property PathSeparator As String
'Usage
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)

Eigenschaftenwert

Die Trennzeichenfolge, die von der TreeNode.FullPath-Eigenschaft des Strukturknotens verwendet wird. Das Standardtrennzeichen ist der umgekehrte Schrägstrich (\).

Hinweise

Der Pfad des Strukturknotens wird aus einer Gruppe von Strukturknotenbezeichnungen gebildet, die durch die PathSeparator-Trennzeichenfolgen getrennt sind. Die Bezeichnungen reichen vom Stammknoten zum gewünschten Strukturknoten.

Beispiel

Im folgenden Codebeispiel wird die PathSeparator-Eigenschaft einer TreeView festgelegt, und die Anzahl der untergeordneten Strukturknoten in der TreeNodeCollection der SelectedNode wird angezeigt. Der prozentuale Anteil der untergeordneten Strukturknoten an der Gesamtzahl der Strukturknoten im Strukturansicht-Steuerelement wird ebenfalls angezeigt. Für dieses Beispiel ist es erforderlich, dass ein Form mit einer Button sowie ein TreeView-Steuerelement mit einer TreeNodeCollection mit mehreren TreeNode-Objekten (vorzugsweise mit drei oder vier Ebenen) vorhanden sind.

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

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

TreeView-Klasse
TreeView-Member
System.Windows.Forms-Namespace
TreeNode.FullPath-Eigenschaft