Proprietà TreeView.PathSeparator (System.Windows.Forms)

Cambia visualizzazione:
ScriptFree
Riferimento a .NET Framework
Proprietà TreeView.PathSeparator

Ottiene o imposta la stringa di delimitazione utilizzata dal percorso del nodo della struttura.

Spazio dei nomi: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Sintassi

Visual Basic - (Dichiarazione)
Public Property PathSeparator As String
Visual Basic (Utilizzo)
Dim instance As TreeView
Dim value As String

value = instance.PathSeparator

instance.PathSeparator = value
C#
public string PathSeparator { get; set; }
C++
public:
property String^ PathSeparator {
	String^ get ();
	void set (String^ value);
}
J#
/** @property */
public String get_PathSeparator ()

/** @property */
public void set_PathSeparator (String value)

JScript
public function get PathSeparator () : String

public function set PathSeparator (value : String)

Valore proprietà

Stringa di delimitazione utilizzata dalla proprietà TreeNode.FullPath del nodo della struttura. Il valore predefinito è il carattere della barra rovesciata (\).
Note

Il percorso del nodo della struttura è composto da una serie di etichette del nodo della struttura separate dalle stringhe di delimitazione PathSeparator. Le etichette sono quelle comprese tra il nodo principale della struttura e il nodo della struttura desiderata.

Esempio

Nell'esempio di codice riportato di seguito viene impostata la proprietà PathSeparator di un oggetto TreeView e viene visualizzato il numero di nodi figlio della struttura contenuti nell'insieme TreeNodeCollection della proprietà SelectedNode. Viene inoltre visualizzata la percentuale di nodi figlio della struttura rispetto al numero totale di nodi della struttura nel controllo visualizzazione struttura. Per eseguire questo esempio è necessario disporre di un oggetto Form con un oggetto Button e di un controllo TreeView con un insieme TreeNodeCollection contenente numerosi oggetti TreeNode preferibilmente in tre o più livelli.

Visual Basic
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

C#
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.");
}

C++
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." ) );
}

J#
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

Piattaforme

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

.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema.

Informazioni sulla versione

.NET Framework

Supportato in: 2.0 1.1 1.0

.NET Compact Framework

Supportato in: 2.0 1.0
Vedere anche