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

TreeView.ExpandAll メソッド

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

ツリー内のすべてのノード開きます

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

Dim instance As TreeView

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

ExpandAll メソッド使用して、TreeView コントロール内のすべてのノード同時に展開する方法次のコード例示します

<%@ Page Language="VB" %>

<script runat="server">

  Sub Button_Command(ByVal sender As
 Object, ByVal e As CommandEventArgs)

    Select Case e.CommandName

      Case "Expand"
        LinksTreeView.ExpandAll()

      Case "Collapse"
        LinksTreeView.CollapseAll()

      Case Else
        ' Do nothing.

    End Select

  End Sub

</script>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeView ExpandAll and CollapseAll Example</h3>
    
      <asp:TreeView id="LinksTreeView"
        Font-Name= "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">
            
              <asp:TreeNode Text="Section 1.0">
              
                <asp:TreeNode Text="Topic 1.0.1"/>
                <asp:TreeNode Text="Topic 1.0.2"/>
                <asp:TreeNode Text="Topic 1.0.3"/>
              
              </asp:TreeNode>
              
              <asp:TreeNode Text="Section 1.1">
              
                <asp:TreeNode Text="Topic 1.1.1"/>
                <asp:TreeNode Text="Topic 1.1.2"/>
                <asp:TreeNode Text="Topic 1.1.3"/>
                <asp:TreeNode Text="Topic 1.1.4"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
            <asp:TreeNode Text="Chapter Two">
            
              <asp:TreeNode Text="Section 2.0">
              
                <asp:TreeNode Text="Topic 2.0.1"/>
                <asp:TreeNode Text="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>
      
      <asp:Button id="ExpandButton" 
        CommandName="Expand"
        Text="Expand All Nodes"
        OnCommand="Button_Command"
        runat="server"/>
         
      &nbsp;
      
      <asp:Button id="CollapseButton" 
        CommandName="Collapse"
        Text="Collapse All Nodes"
        OnCommand="Button_Command"
        runat="server"/>

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

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

<script runat="server">

  void Button_Command(Object sender, CommandEventArgs e)
  {

    switch(e.CommandName)
    {

      case "Expand":
        LinksTreeView.ExpandAll();
        break;
      case "Collapse":
        LinksTreeView.CollapseAll();
        break;
      default:
        // Do nothing.
        break;

    }

  }

</script>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeView ExpandAll and CollapseAll Example</h3>
    
      <asp:TreeView id="LinksTreeView"
        Font-Name= "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">
            
              <asp:TreeNode Text="Section 1.0">
              
                <asp:TreeNode Text="Topic 1.0.1"/>
                <asp:TreeNode Text="Topic 1.0.2"/>
                <asp:TreeNode Text="Topic 1.0.3"/>
              
              </asp:TreeNode>
              
              <asp:TreeNode Text="Section 1.1">
              
                <asp:TreeNode Text="Topic 1.1.1"/>
                <asp:TreeNode Text="Topic 1.1.2"/>
                <asp:TreeNode Text="Topic 1.1.3"/>
                <asp:TreeNode Text="Topic 1.1.4"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
            <asp:TreeNode Text="Chapter Two">
            
              <asp:TreeNode Text="Section 2.0">
              
                <asp:TreeNode Text="Topic 2.0.1"/>
                <asp:TreeNode Text="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>
      
      <asp:Button id="ExpandButton" 
        CommandName="Expand"
        Text="Expand All Nodes"
        OnCommand="Button_Command"
        runat="server"/>
         
      &nbsp;
      
      <asp:Button id="CollapseButton" 
        CommandName="Collapse"
        Text="Collapse All Nodes"
        OnCommand="Button_Command"
        runat="server"/>

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

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

TreeView.ExpandAll メソッド

すべてのツリー ノード展開します

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

Dim instance As TreeView

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

Checkboxオンになったとき TreeView コントロールツリー ノードをすべて展開しCheckboxオフになったときに FirstNode を折りたたむコード例次に示します。この例は、Form 上に、CheckboxTreeView コントロール配置され、その TreeView に、複数TreeNode オブジェクト (3 レベル以上を推奨) を持つ TreeNodeCollection が設定されていることを前提にしています。

Private Sub myCheckBox_CheckedChanged(ByVal
 sender As Object, _
   ByVal e As System.EventArgs) Handles
 myCheckBox.CheckedChanged
   ' If the check box is checked, expand all the tree nodes.
   If myCheckBox.Checked = True Then
      myTreeView.ExpandAll()
   Else
      ' If the check box is not cheked, collapse the first tree node.
      myTreeView.Nodes(0).FirstNode.Collapse()
      MessageBox.Show("The first and last node of CutomerList
 root node is collapsed")
   End If
End Sub
private void myCheckBox_CheckedChanged(object
 sender, System.EventArgs e)
{
   // If the check box is checked, expand all the tree nodes.
   if (myCheckBox.Checked == true)
   {
      myTreeView.ExpandAll();
   }
   else
   {
      // If the check box is not cheked, collapse the first tree node.
      myTreeView.Nodes[0].FirstNode.Collapse();
      MessageBox.Show("The first and last  node of CutomerList root node is
 collapsed");
   }
}
void myCheckBox_CheckedChanged( Object^ /*sender*/, System::EventArgs^
 /*e*/ )
{
   
   // If the check box is checked, expand all the tree nodes.
   if ( myCheckBox->Checked == true )
   {
      myTreeView->ExpandAll();
   }
   else
   {
      
      // If the check box is not cheked, collapse the first tree node.
      myTreeView->Nodes[ 0 ]->FirstNode->Collapse();
      MessageBox::Show( "The first and last  node of CutomerList root node is
 collapsed" );
   }
}
private void myCheckBox_CheckedChanged(Object
 sender, System.EventArgs e)
{
    // If the check box is checked, expand all the tree nodes.
    if (myCheckBox.get_Checked() == true) {
 
        myTreeView.ExpandAll();
    }
    else {
        // If the check box is not cheked, collapse the first tree node.
        myTreeView.get_Nodes().get_Item(0).get_FirstNode().Collapse();
        MessageBox.Show("The first and last  node of CutomerList root "
            + "node is collapsed");
    }
} //myCheckBox_CheckedChanged
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「TreeView.ExpandAll」の関連用語

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

   

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



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

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

©2024 GRAS Group, Inc.RSS