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

Dim instance As MenuItemCollection Dim index As Integer Dim value As MenuItem value = instance(index)
プロパティ値
現在の MenuItemCollection 内の指定したインデックス位置にある MenuItem。

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

このインデクサを使用して、Menu コントロールの Items コレクションからルート メニュー項目を取得する方法のコード例を次に示します。
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not IsPostBack Then ' Retrieve the root menu item from the Items ' collection of the Menu control using the indexer. Dim homeMenuItem As MenuItem = NavigationMenu.Items(0) ' Create the submenu item. Dim newSubMenuItem = New MenuItem("New Category") ' Add the submenu item to the ChildItems ' collection of the root menu item. homeMenuItem.ChildItems.Add(newSubMenuItem) End If End Sub </script> <html> <body> <form runat="server"> <h3>MenuItemCollection Add Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"> <items> <asp:menuitem text="Home" tooltip="Home"> <asp:menuitem text="Music" tooltip="Music"> <asp:menuitem text="Classical" tooltip="Classical"/> <asp:menuitem text="Rock" tooltip="Rock"/> <asp:menuitem text="Jazz" tooltip="Jazz"/> </asp:menuitem> <asp:menuitem text="Movies" tooltip="Movies"> <asp:menuitem text="Action" tooltip="Action"/> <asp:menuitem text="Drama" tooltip="Drama"/> <asp:menuitem text="Musical" tooltip="Musical"/> </asp:menuitem> </asp:menuitem> </items> </asp:menu> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void Page_Load(Object sender, EventArgs e) { if (!IsPostBack) { // Retrieve the root menu item from the Items // collection of the Menu control using the indexer. MenuItem homeMenuItem = NavigationMenu.Items[0]; // Create the submenu item. MenuItem newSubMenuItem = new MenuItem("New Category"); // Add the submenu item to the ChildItems // collection of the root menu item. homeMenuItem.ChildItems.Add(newSubMenuItem); } } </script> <html> <body> <form runat="server"> <h3>MenuItemCollection Add Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"> <items> <asp:menuitem text="Home" tooltip="Home"> <asp:menuitem text="Music" tooltip="Music"> <asp:menuitem text="Classical" tooltip="Classical"/> <asp:menuitem text="Rock" tooltip="Rock"/> <asp:menuitem text="Jazz" tooltip="Jazz"/> </asp:menuitem> <asp:menuitem text="Movies" tooltip="Movies"> <asp:menuitem text="Action" tooltip="Action"/> <asp:menuitem text="Drama" tooltip="Drama"/> <asp:menuitem text="Musical" tooltip="Musical"/> </asp:menuitem> </asp:menuitem> </items> </asp:menu> </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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からMenuItemCollection.Item プロパティを検索する場合は、下記のリンクをクリックしてください。

- MenuItemCollection.Item プロパティのページへのリンク