TreeNodeCollection.Item プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As TreeNodeCollection Dim index As Integer Dim value As TreeNode value = instance(index)
プロパティ値
TreeNodeCollection 内の指定したインデックス位置の TreeNode オブジェクト。

このインデクサを使用して、配列表記で指定したインデックス位置にある TreeNodeCollection から TreeNode オブジェクトにアクセスします。このインデクサを使用して、直接、コレクション内の TreeNode オブジェクトを変更または置換できます。コレクションのインデックスは 0 から始まります。

インデクサを使用して 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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


TreeNodeCollection.Item プロパティ

名前 | 説明 |
---|---|
TreeNodeCollection.Item (Int32) | コレクション内の指定したインデックス位置にある TreeNode を取得または設定します。 .NET Compact Framework によってサポートされています。 |
TreeNodeCollection.Item (String) | 指定したキーのツリー ノードをコレクションから取得します。 |

関連項目
TreeNodeCollection クラスTreeNodeCollection メンバ
System.Windows.Forms 名前空間
TreeNodeCollection.Count プロパティ
Weblioに収録されているすべての辞書からTreeNodeCollection.Itemを検索する場合は、下記のリンクをクリックしてください。

- TreeNodeCollection.Itemのページへのリンク