TreeView.FindNode メソッドとは? わかりやすく解説

TreeView.FindNode メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

指定された値パスにある TreeView コントロール内の TreeNode オブジェクト取得します

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

Public Function FindNode ( _
    valuePath As String _
) As TreeNode
Dim instance As TreeView
Dim valuePath As String
Dim returnValue As TreeNode

returnValue = instance.FindNode(valuePath)
public TreeNode FindNode (
    string valuePath
)
public:
TreeNode^ FindNode (
    String^ valuePath
)
public TreeNode FindNode (
    String valuePath
)
public function FindNode (
    valuePath : String
) : TreeNode

パラメータ

valuePath

ノードの値パス

戻り値
指定したパスにある TreeNode

解説解説
使用例使用例

FindNode メソッド使用してTreeView コントロールかノード取得するコード例次に示します

<%@ Page Language="VB" %>

<script runat="server">

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

    ' Find the node specified by the user.
    Dim node As TreeNode = LinksTreeView.FindNode(Server.HtmlEncode(ValuePathText.Text))

    If Not node Is Nothing
 Then

      ' Indicate that the node was found.
      Message.Text = "The specified node (" &
 node.ValuePath & ") was found."

    Else

      ' Indicate that the node is not in the TreeView control.
      Message.Text = "The specified node (" &
 ValuePathText.Text & ") is not in this TreeView control."

    End If

  End Sub

</script>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeView FindNode Example</h3>
    
      <asp:TreeView id="LinksTreeView"
        PathSeparator="\"
        Font-Names= "Arial"
        ForeColor="Blue" 
        runat="server">
         
        <LevelStyles>
        
          <asp:TreeNodeStyle ChildNodesPadding="10"
 
            Font-Bold="true" 
            Font-Size="12pt" 
            ForeColor="DarkGreen"/>
          <asp:TreeNodeStyle ChildNodesPadding="5"
 
            Font-Bold="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="5"
 
            Font-UnderLine="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="10"
 
            Font-Size="8pt"/>
             
        </LevelStyles>
         
        <Nodes>
        
          <asp:TreeNode Text="Table of Contents"
            SelectAction="None">
             
            <asp:TreeNode Text="Chapter One" Value="Chapter
 One">
            
              <asp:TreeNode Text="Section 1.0"
 Value="Section 1.0">
              
                <asp:TreeNode Text="Topic 1.0.1"
 Value="Topic 1.0.1"/>
                <asp:TreeNode Text="Topic 1.0.2"
 Value="Topic 1.0.2"/>
                <asp:TreeNode Text="Topic 1.0.3"
 Value="Topic 1.0.3"/>
              
              </asp:TreeNode>
              
              <asp:TreeNode Text="Section 1.1">
              
                <asp:TreeNode Text="Topic 1.1.1"
 Value="Topic 1.1.1"/>
                <asp:TreeNode Text="Topic 1.1.2"
 Value="Topic 1.1.2"/>
                <asp:TreeNode Text="Topic 1.1.3"
 Value="Topic 1.1.3"/>
                <asp:TreeNode Text="Topic 1.1.4"
 Value="Topic 1.1.4"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
            <asp:TreeNode Text="Chapter Two" Value="Chapter
 Two">
            
              <asp:TreeNode Text="Section 2.0"
 Value="Section 2.0">
              
                <asp:TreeNode Text="Topic 2.0.1"
 Value="Topic 2.0.1"/>
                <asp:TreeNode Text="Topic 2.0.2"
 Value="Topic 2.0.2"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
          </asp:TreeNode>
          <asp:TreeNode Text="Appendix A" />
          <asp:TreeNode Text="Appendix B" />
          <asp:TreeNode Text="Appendix C" />
        
        </Nodes>
        
      </asp:TreeView>
      
      <hr>
      
      <br><br>
      
      Enter the value path of the node to locate.
 <br>
      Use a backslash (\) to delimit each node
 value.<br>
      <asp:TextBox id="ValuePathText" 
        Text="Table of Contents\Chapter One\Section 1.0"
        Width="50%" 
        runat="server"/>
         
      <br><br>
      
      <asp:Button id="Submit"
        Text="Find Node"
        OnClick="Button_Click"  
        runat="server"/>
      
      <br><br>
      
      <asp:Label id="Message" runat="server"/>

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

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

<script runat="server">

  void Button_Click(Object sender, EventArgs e)
  {

    // Find the node specified by the user.
    TreeNode node = LinksTreeView.FindNode(Server.HtmlEncode(ValuePathText.Text));

    if (node != null)
    {
      // Indicate that the node was found.
      Message.Text = "The specified node (" + node.ValuePath + ")
 was found.";
    }
    else
    {
      // Indicate that the node is not in the TreeView control.
      Message.Text = "The specified node (" + ValuePathText.Text + ")
 is not in this TreeView control.";
    }

  }

</script>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeView FindNode Example</h3>
    
      <asp:TreeView id="LinksTreeView"
        PathSeparator="\"
        Font-Names= "Arial"
        ForeColor="Blue" 
        runat="server">
         
        <LevelStyles>
        
          <asp:TreeNodeStyle ChildNodesPadding="10" 
            Font-Bold="true" 
            Font-Size="12pt" 
            ForeColor="DarkGreen"/>
          <asp:TreeNodeStyle ChildNodesPadding="5" 
            Font-Bold="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="5" 
            Font-UnderLine="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="10" 
            Font-Size="8pt"/>
             
        </LevelStyles>
         
        <Nodes>
        
          <asp:TreeNode Text="Table of Contents"
            SelectAction="None">
             
            <asp:TreeNode Text="Chapter One" Value="Chapter One">
            
              <asp:TreeNode Text="Section 1.0" Value="Section 1.0">
              
                <asp:TreeNode Text="Topic 1.0.1" Value="Topic 1.0.1"/>
                <asp:TreeNode Text="Topic 1.0.2" Value="Topic 1.0.2"/>
                <asp:TreeNode Text="Topic 1.0.3" Value="Topic 1.0.3"/>
              
              </asp:TreeNode>
              
              <asp:TreeNode Text="Section 1.1">
              
                <asp:TreeNode Text="Topic 1.1.1" Value="Topic 1.1.1"/>
                <asp:TreeNode Text="Topic 1.1.2" Value="Topic 1.1.2"/>
                <asp:TreeNode Text="Topic 1.1.3" Value="Topic 1.1.3"/>
                <asp:TreeNode Text="Topic 1.1.4" Value="Topic 1.1.4"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
            <asp:TreeNode Text="Chapter Two" Value="Chapter Two">
            
              <asp:TreeNode Text="Section 2.0" Value="Section 2.0">
              
                <asp:TreeNode Text="Topic 2.0.1" Value="Topic 2.0.1"/>
                <asp:TreeNode Text="Topic 2.0.2" Value="Topic 2.0.2"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
          </asp:TreeNode>
          <asp:TreeNode Text="Appendix A" />
          <asp:TreeNode Text="Appendix B" />
          <asp:TreeNode Text="Appendix C" />
        
        </Nodes>
        
      </asp:TreeView>
      
      <hr>
      
      <br><br>
      
      Enter the value path of the node to locate. <br>
      Use a backslash (\) to delimit each node value.<br>
      <asp:TextBox id="ValuePathText" 
        Text="Table of Contents\Chapter One\Section 1.0"
        Width="50%" 
        runat="server"/>
         
      <br><br>
      
      <asp:Button id="Submit"
        Text="Find Node"
        OnClick="Button_Click"  
        runat="server"/>
      
      <br><br>
      
      <asp:Label id="Message" runat="server"/>

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

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


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

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

辞書ショートカット

すべての辞書の索引

TreeView.FindNode メソッドのお隣キーワード
検索ランキング

   

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



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

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

©2024 GRAS Group, Inc.RSS