MenuItemCollection.Item プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > MenuItemCollection.Item プロパティの意味・解説 

MenuItemCollection.Item プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

現在の MenuItemCollection オブジェクト内の指定したインデックス位置にある MenuItem オブジェクト取得します

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

Dim instance As MenuItemCollection
Dim index As Integer
Dim value As MenuItem

value = instance(index)
public MenuItem this [
    int index
] { get; }
public:
property MenuItem^ default [int] {
    MenuItem^ get (int index);
}
/** @property */
public MenuItem get_Item (int index)

パラメータ

index

取得する MenuItem の、0 から始まるインデックス番号

プロパティ
現在の MenuItemCollection 内の指定したインデックス位置にある 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>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MenuItemCollection クラス
MenuItemCollection メンバ
System.Web.UI.WebControls 名前空間
Menu クラス
MenuItem クラス
Menu.Items プロパティ
MenuItem.ChildItems プロパティ
GetEnumerator
CopyTo


このページでは「.NET Framework クラス ライブラリ リファレンス」からMenuItemCollection.Item プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からMenuItemCollection.Item プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からMenuItemCollection.Item プロパティ を検索

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

辞書ショートカット

すべての辞書の索引

MenuItemCollection.Item プロパティのお隣キーワード
検索ランキング

   

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



MenuItemCollection.Item プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS