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

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > TreeNode.CollapseAll メソッドの意味・解説 

TreeNode.CollapseAll メソッド

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

現在のノードとそのすべての子ノード折りたたみます。

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

Dim instance As TreeNode

instance.CollapseAll
public void CollapseAll ()
public:
void CollapseAll ()
public void CollapseAll ()
解説解説
使用例使用例

CollapseAll メソッド使用してプログラムによって TreeView コントロールノードとそのすべての子ノード折りたたむ方法次のコード例示します。この例を正常に動作させるには、以下のサンプル XML データを、Book.xml という名前のファイルコピーする必要があります

<%@ Page Language="VB" %>

<script runat="server">

  Sub Data_Bound(ByVal sender As
 Object, ByVal e As TreeNodeEventArgs)

    ' Determine the depth of a node as it is bound to data.
    ' If the depth is 1, expand the node.
    If e.Node.Depth = 1 Then

      ' Expand the node using the ExpandAll method.
      e.Node.ExpandAll()

    Else

      ' Collapse the node using the CollapseAll method.
      e.Node.CollapseAll()

    End If

  End Sub

</script>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeNode ExpandAll and CollapseAll Example</h3>
      
      <h5>Expand the root node. Notice that the child nodes are already expanded.</h5>
    
      <asp:TreeView id="BookTreeView" 
         DataSourceID="BookXmlDataSource"
         OnTreeNodeDataBound="Data_Bound"
         runat="server">
         
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Book"
 TextField="Title"/>
          <asp:TreeNodeBinding DataMember="Chapter"
 TextField="Heading"/>
          <asp:TreeNodeBinding DataMember="Section"
 TextField="Heading"/>
        </DataBindings>
         
      </asp:TreeView>
      
      <asp:XmlDataSource id="BookXmlDataSource"
  
         DataFile="Book.xml"
         runat="server">
      </asp:XmlDataSource>
    
    </form>
  </body>
</html>

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

<script runat="server">

  void Data_Bound(Object sender, TreeNodeEventArgs e)
  {

    // Determine the depth of a node as it is bound to data.
    // If the depth is 1, expand the node.
    if(e.Node.Depth == 1)
    {

      // Expand the node using the ExpandAll method.
      e.Node.ExpandAll();

    }
    else
    {

      // Collapse the node using the CollapseAll method.
      e.Node.CollapseAll();

    }

  }

</script>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeNode ExpandAll and CollapseAll Example</h3>
      
      <h5>Expand the root node. Notice that the child nodes are already expanded.</h5>
    
      <asp:TreeView id="BookTreeView" 
         DataSourceID="BookXmlDataSource"
         OnTreeNodeDataBound="Data_Bound"
         runat="server">
         
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Book" TextField="Title"/>
          <asp:TreeNodeBinding DataMember="Chapter" TextField="Heading"/>
          <asp:TreeNodeBinding DataMember="Section" TextField="Heading"/>
        </DataBindings>
         
      </asp:TreeView>
      
      <asp:XmlDataSource id="BookXmlDataSource"  
         DataFile="Book.xml"
         runat="server">
      </asp:XmlDataSource>
    
    </form>
  </body>
</html>

前の例のサンプル XML データ次のコード示します

<Book Title="Book Title">
    <Chapter Heading="Chapter 1">
        <Section Heading="Section 1">
        </Section>
        <Section Heading="Section 2">
        </Section>
    </Chapter>
    <Chapter Heading="Chapter 2">
        <Section Heading="Section 1">
        </Section>
    </Chapter>
</Book>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TreeNode クラス
TreeNode メンバ
System.Web.UI.WebControls 名前空間
TreeView
Expanded
Collapse
Expand
ExpandAll
CollapseAll


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

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS