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



Clear メソッドを使用して、Menu コントロールの Items コレクションからすべての項目を削除する方法のコード例を次に示します。
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not IsPostBack Then ' Use the Clear method to remove all ' menu items from the Items collection ' of the Menu control. NavigationMenu.Items.Clear() ' Create the menu structure. ' Create the root menu item. Dim homeMenuItem As New MenuItem("Home") ' Create the submenu items. Dim musicSubMenuItem As New MenuItem("Music") Dim moviesSubMenuItem As New MenuItem("Movies") ' Add the submenu items to the ChildItems ' collection of the root menu item. homeMenuItem.ChildItems.Add(musicSubMenuItem) homeMenuItem.ChildItems.Add(moviesSubMenuItem) ' Add the root menu item to the Items collection ' of the Menu control. NavigationMenu.Items.Add(homeMenuItem) End If End Sub </script> <html> <body> <form runat="server"> <h3>MenuItemCollection Clear Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void Page_Load(Object sender, EventArgs e) { if (!IsPostBack) { // Use the Clear method to remove all // menu items from the Items collection // of the Menu control. NavigationMenu.Items.Clear(); // Create the menu structure. // Create the root menu item. MenuItem homeMenuItem = new MenuItem("Home"); // Create the submenu items. MenuItem musicSubMenuItem = new MenuItem("Music"); MenuItem moviesSubMenuItem = new MenuItem("Movies"); // Add the submenu items to the ChildItems // collection of the root menu item. homeMenuItem.ChildItems.Add(musicSubMenuItem); homeMenuItem.ChildItems.Add(moviesSubMenuItem); // Add the root menu item to the Items collection // of the Menu control. NavigationMenu.Items.Add(homeMenuItem); } } </script> <html> <body> <form runat="server"> <h3>MenuItemCollection Clear Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"/> </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.Clear メソッドを検索する場合は、下記のリンクをクリックしてください。

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