TreeView.PathSeparatorとは? わかりやすく解説

TreeView.PathSeparator プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

ValuePath プロパティによって指定されノード値を区切るために使用される文字取得または設定します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Dim instance As TreeView
Dim value As Char

value = instance.PathSeparator

instance.PathSeparator = value
public char PathSeparator { get;
 set; }
public:
property wchar_t PathSeparator {
    wchar_t get ();
    void set (wchar_t value);
}
/** @property */
public char get_PathSeparator ()

/** @property */
public void set_PathSeparator (char
 value)
public function get PathSeparator
 () : char

public function set PathSeparator
 (value : char)

プロパティ
ValuePath プロパティ指定されノード値を区切るために使用される文字既定値スラッシュ (/) です。

解説解説
使用例使用例

PathSeparator プロパティ使用してノードValuePath プロパティ区切り文字指定するコード例次に示します。この値は次に個々の値の ValuePath プロパティ解析するために使用されます。

<%@ Page Language="VB" %>

<script runat="server">

  Sub Index_Changed(ByVal sender As
 Object, ByVal e As EventArgs)

    ' Set the PathSeparator character based on the user's selection.
    ' Notice that the value must be converted to a Char data type.
    BookTreeView.PathSeparator = Convert.ToChar(List.SelectedItem.Text)

    ' Display the ValuePath values for the second-level nodes.
    Message.Text = "The ValuePath values for the second-level
 nodes are:<br>"
    Dim node As TreeNode
    For Each node In BookTreeView.Nodes(0).ChildNodes

      ' Create the delimiter array with the PathSeparator value for
 the Split method.
      Dim DelimiterArray(1) As Char
      DelimiterArray(0) = BookTreeView.PathSeparator

      ' Parse the ValuePath value using the delimiter array.
      Dim NodeValues() As String
 = node.ValuePath.Split(DelimiterArray)

      ' Display the node values.
      Dim i As Integer

      For i = 0 To NodeValues.Length - 1

        If i <> NodeValues.Length - 1 Then

          ' Append the delimiter character.
          Message.Text &= NodeValues(i) & BookTreeView.PathSeparator.ToString()

        Else

          ' Do not append the delimiter character.
          Message.Text &= NodeValues(i)

        End If

      Next

      ' Append a line break for the next node.
      Message.Text &= "<br>"

    Next

  End Sub

</script>

<html>

  <body>
    <form runat="server">
    
      <h3>TreeView PathSeparator Example</h3>
      
      <asp:TreeView id="BookTreeView"
        InitialExpandDepth="-1"
        PathSeparator="/"
        runat="server">
         
        <Nodes>
        
          <asp:TreeNode Value="Chapter 1" 
            Text="Chapter 1">
             
            <asp:TreeNode Value="Section 1"
              Text="Section 1">
               
              <asp:TreeNode Value="Paragraph 1"
 
                Text="Paragraph 1">
              </asp:TreeNode>
                
            </asp:TreeNode>
            
            <asp:TreeNode Value="Section 2" 
              Text="Section 2">
            </asp:TreeNode>
            
          </asp:TreeNode>
        
        </Nodes>
        
      </asp:TreeView>
      
      <br>
      
      <asp:Label id="Message" runat="server"/>
      
      <hr>
      
      Select a path separator value:<br>
      
      <asp:DropDownList ID="List"
        AutoPostBack="true"
        OnSelectedIndexChanged="Index_Changed"   
        runat="server">
      
        <asp:ListItem Selected="true">/</asp:ListItem>
        <asp:ListItem>\</asp:ListItem>
        <asp:ListItem>|</asp:ListItem>
        <asp:ListItem>,</asp:ListItem>
        <asp:ListItem>;</asp:ListItem>
      
      </asp:DropDownList>

    </form>
  </body>
</html>

<%@ Page Language="C#" %>

<script runat="server">

  void Index_Changed(Object sender, EventArgs e)
  {

    // Set the PathSeparator character based on the user's selection.
    // Notice that the value must be converted to a Char data type.
    BookTreeView.PathSeparator = Convert.ToChar(List.SelectedItem.Text);

    // Display the ValuePath values for the second-level nodes.
    Message.Text = "The ValuePath values for the second-level
 nodes are:<br>";
    foreach(TreeNode node in BookTreeView.Nodes[0].ChildNodes)
    {

      // Create the delimiter array with the PathSeparator value for
 the Split method.
      Char[] DelimiterArray = new Char[1];
      DelimiterArray[0] = BookTreeView.PathSeparator;

      // Parse the ValuePath value using the delimiter array.
      String[] NodeValues = node.ValuePath.Split(DelimiterArray);

      // Display the node values.
      for(int i=0; i<NodeValues.Length;
 i++)
      {
        if(i != NodeValues.Length - 1)
        {   
          // Append the delimiter character.
          Message.Text += NodeValues[i] + BookTreeView.PathSeparator.ToString();
        }
        else
        {
          // Do not append the delimiter character.
          Message.Text += NodeValues[i];
        }

      }

      // Append a line break for the next node.
      Message.Text += "<br>";

    }

  }

</script>

<html>

  <body>
    <form runat="server">
    
      <h3>TreeView PathSeparator Example</h3>
      
      <asp:TreeView id="BookTreeView"
        InitialExpandDepth="-1"
        PathSeparator="/"
        runat="server">
         
        <Nodes>
        
          <asp:TreeNode Value="Chapter 1" 
            Text="Chapter 1">
             
            <asp:TreeNode Value="Section 1"
              Text="Section 1">
               
              <asp:TreeNode Value="Paragraph 1" 
                Text="Paragraph 1">
              </asp:TreeNode>
                
            </asp:TreeNode>
            
            <asp:TreeNode Value="Section 2" 
              Text="Section 2">
            </asp:TreeNode>
            
          </asp:TreeNode>
        
        </Nodes>
        
      </asp:TreeView>
      
      <br>
      
      <asp:Label id="Message" runat="server"/>
      
      <hr>
      
      Select a path separator value:<br>
      
      <asp:DropDownList ID="List"
        AutoPostBack="true"
        OnSelectedIndexChanged="Index_Changed"   
        runat="server">
      
        <asp:ListItem Selected="true">/</asp:ListItem>
        <asp:ListItem>\</asp:ListItem>
        <asp:ListItem>|</asp:ListItem>
        <asp:ListItem>,</asp:ListItem>
        <asp:ListItem>;</asp:ListItem>
      
      </asp:DropDownList>

    </form>
  </body>
</html>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TreeView クラス
TreeView メンバ
System.Web.UI.WebControls 名前空間
TreeNode.ValuePath プロパティ

TreeView.PathSeparator プロパティ

ツリー ノードパス使用する区切り記号取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

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 プロパティ使用する区切り記号既定値は、円記号 (\) です。

解説解説
使用例使用例

TreeView の PathSeparator プロパティ設定し、SelectedNode の TreeNodeCollection に含まれている子ツリー ノードの数を表示するコード例次に示しますツリー ビュー コントロール内のすべてのツリー ノード対する子ツリー ノード割合表示されます。この例は、Form 上に、ButtonTreeView コントロール配置され、その 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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からTreeView.PathSeparatorを検索した結果を表示しています。
Weblioに収録されているすべての辞書からTreeView.PathSeparatorを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からTreeView.PathSeparator を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「TreeView.PathSeparator」の関連用語

TreeView.PathSeparatorのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TreeView.PathSeparatorのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS