MenuItemCollection.AddAt メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim instance As MenuItemCollection Dim index As Integer Dim child As MenuItem instance.AddAt(index, child)


AddAt メソッドを使用して、MenuItemCollection オブジェクトの指定したインデックス位置に MenuItem オブジェクトをプログラムによって挿入する方法のコード例を次に示します。
<%@ 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. Dim homeMenuItem As MenuItem = NavigationMenu.Items(0) ' Create the submenu item. Dim newSubMenuItem = New MenuItem("New Category") ' Insert the submenu item in the ChildItems ' collection of the root menu item at index 0. homeMenuItem.ChildItems.AddAt(0, newSubMenuItem) End If End Sub </script> <html> <body> <form runat="server"> <h3>MenuItemCollection AddAt 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. MenuItem homeMenuItem = NavigationMenu.Items[0]; // Create the submenu item. MenuItem newSubMenuItem = new MenuItem("New Category"); // Insert the submenu item in the ChildItems // collection of the root menu item at index 0. homeMenuItem.ChildItems.AddAt(0, newSubMenuItem); } } </script> <html> <body> <form runat="server"> <h3>MenuItemCollection AddAt 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.AddAt メソッドを検索する場合は、下記のリンクをクリックしてください。

- MenuItemCollection.AddAt メソッドのページへのリンク