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

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

TreeNodeCollection.AddAt メソッド

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

指定した TreeNode オブジェクトを、TreeNodeCollection オブジェクト指定したインデックス位置挿入します

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

Public Sub AddAt ( _
    index As Integer, _
    child As TreeNode _
)
Dim instance As TreeNodeCollection
Dim index As Integer
Dim child As TreeNode

instance.AddAt(index, child)
public void AddAt (
    int index,
    TreeNode child
)
public:
void AddAt (
    int index, 
    TreeNode^ child
)
public void AddAt (
    int index, 
    TreeNode child
)
public function AddAt (
    index : int, 
    child : TreeNode
)

パラメータ

index

TreeNode オブジェクト挿入する位置の、0 から始まるインデックス

child

追加する TreeNode オブジェクト

解説解説

AddAt メソッド使用して指定した TreeNode オブジェクトTreeNodeCollection指定した 0 から始まるインデックス位置挿入します

メモメモ

TreeNodeCollection使用すると、null 参照 (Visual Basic の場合は Nothing) だけでなく、複製した TreeNode オブジェクト挿入できます

または、Add メソッド使用してTreeNode オブジェクトTreeNodeCollection末尾追加することもできます

使用例使用例

AddAt メソッド使用してプログラムノードTreeNodeCollection追加する方法の例を次に示しますNodes プロパティおよび ChildNodes プロパティは、それぞれ TreeNodeCollection オブジェクト返します

<%@ Page Language="VB" %>

<script runat="server">

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

    If Not IsPostBack Then

      ' Use the Add and Remove methods to programmatically 
      ' remove the Appendix C node and replace it with a new 
      ' node. 
      LinksTreeView.Nodes.Remove(LinksTreeView.Nodes(3))
      LinksTreeView.Nodes.Add(New TreeNode("New
 Appendix C"))

      ' Use the AddAt and RemoveAt methods to programmatically 
      ' remove the Chapter One node and replace it with a new node.
      LinksTreeView.Nodes(0).ChildNodes.RemoveAt(0)
      LinksTreeView.Nodes(0).ChildNodes.AddAt(0, New TreeNode("New
 Chapter One"))

      ' Use the Clear method to remove all the child nodes of the 
      ' Chapter Two node.
      LinksTreeView.Nodes(0).ChildNodes(1).ChildNodes.Clear()

    End If

  End Sub

</script>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeNodeCollection 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"
            Expanded="true">
             
            <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>

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

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

<script runat="server">

  void Page_Load(Object sender, EventArgs e)
  {

    if (!IsPostBack)
    {

      // Use the Add and Remove methods to programmatically 
      // remove the Appendix C node and replace it with a new 
      // node. 
      LinksTreeView.Nodes.Remove(LinksTreeView.Nodes[3]);
      LinksTreeView.Nodes.Add(new TreeNode("New Appendix
 C"));

      // Use the AddAt and RemoveAt methods to programmatically 
      // remove the Chapter One node and replace it with a new node.
      LinksTreeView.Nodes[0].ChildNodes.RemoveAt(0);
      LinksTreeView.Nodes[0].ChildNodes.AddAt(0, new TreeNode("New
 Chapter One"));

      // Use the Clear method to remove all the child nodes of the 
      // Chapter Two node.
      LinksTreeView.Nodes[0].ChildNodes[1].ChildNodes.Clear();

    }

  }

</script>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeNodeCollection 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"
            Expanded="true">
             
            <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>

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

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



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2024 GRAS Group, Inc.RSS