TreeNode.ValuePath プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > TreeNode.ValuePath プロパティの意味・解説 

TreeNode.ValuePath プロパティ

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

ルート ノードから現在のノードまでのパス取得します

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

解説解説

ValuePath プロパティには、ルート ノードから現在のノードまでのパス構成するノードの値のコンマ区切りリスト格納されます。ノードの値を区切るための区切り文字指定するには、PathSeparator プロパティ使用します通常この値は、個々の値についてリスト解析する場合や、TreeView クラスの FindNode メソッド引数として渡す場合使用されます。

TreeView コントロール表示される値によっては、競合を防ぐために区切り文字変更する必要があります。たとえば、区切り文字コンマ設定した場合は、表示値にコンマ入れないくださいコンマ入れると、ValuePath プロパティ正確に解析できません。

メモメモ

同じレベルにあるノードは、それぞれの Value プロパティの値が一意であることが必要です。同一レベル複数ノードでこの値が同じであると、TreeView コントロールは各ノード区別できません。この場合重複した値を持つノードユーザークリックすると、最初に TreeView コントロール表示されているノード選択されます。

使用例使用例

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>

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


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

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

辞書ショートカット

すべての辞書の索引

「TreeNode.ValuePath プロパティ」の関連用語

TreeNode.ValuePath プロパティのお隣キーワード
検索ランキング

   

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



TreeNode.ValuePath プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS