MenuItemStyleCollectionとは? わかりやすく解説

MenuItemStyleCollection クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

Menu コントロール内の MenuItemStyle オブジェクトコレクション表します。このクラス継承できません。

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

Public NotInheritable Class
 MenuItemStyleCollection
    Inherits StateManagedCollection
Dim instance As MenuItemStyleCollection
public sealed class MenuItemStyleCollection
 : StateManagedCollection
public ref class MenuItemStyleCollection sealed
 : public StateManagedCollection
public final class MenuItemStyleCollection
 extends StateManagedCollection
public final class MenuItemStyleCollection
 extends StateManagedCollection
解説解説

MenuItemStyleCollection クラスは、Menu コントロール内の MenuItemStyle オブジェクトコレクション格納および管理する場合使用されます。Menu コントロールは、MenuItemStyleCollection クラスを、LevelMenuItemStyles プロパティおよび LevelSelectedStyles プロパティの基になるデータ型として使用します

LevelMenuItemStyles プロパティLevelSelectedStyles プロパティは、個々スタイル プロパティ (StaticMenuItemStyle など) の代わりに使用します。これらのプロパティは、メニュー内のメニュー項目レベル基づいてそれぞれ標準メニュー項目と選択されメニュー項目に適用されます。このコレクションの中の最初スタイルは、メニュー最初レベルメニュー項目スタイル対応します。このコレクションの中の 2 番目のスタイルは、メニュー2 番目のレベルメニュー項目スタイル対応し、以下同様に対応しますLevelMenuItemStyles プロパティLevelSelectedStyles プロパティが最も多く使われるのは、サブメニューの有無かかわらず特定のレベルにあるメニュー項目の外観が同じメニュー生成する場合です。

MenuItemStyleCollection クラスは、StateManagedCollection クラスのほとんどのメンバ継承します継承メンバ詳細については、StateManagedCollectionトピック参照してください

使用例使用例

MenuItemStyleCollection クラス使用してメニュー項目のレベル基づいて Menu コントロールメニュー項目にスタイル設定指定する方法コード例次に示します。この例では、LevelMenuItemStyles プロパティ宣言によって作成され1 つMenuItemStyle オブジェクト削除され別のオブジェクトMenuItemStyleCollection オブジェクト追加されています。

<%@ 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 RemoveAt methods to programmatically 
        ' remove the third level menu item style and replace 
        ' it with a new style, in this case replacing the green background
        ' and yellow text with the blue background and white text. 
        Dim newStyle As New
 MenuItemStyle()
        newStyle.BackColor = System.Drawing.Color.Blue
        newStyle.ForeColor = System.Drawing.Color.White
        
        ' Remove the last of the three menu item styles. Note that
        ' since the collection has a zero-based index, the third
        ' entry has an index value of 2.
        MainMenuID.LevelMenuItemStyles.RemoveAt(2)
        MainMenuID.LevelMenuItemStyles.Add(newStyle)
    End If
 
End Sub 'Page_Load
</script>

<html>
  <body>
    <form runat="server">
    
      <h3>MenuItemStyleCollection Example</h3>
         <!--Add MenuItemStyle objects to the MenuItemStyleCollection
 -->
         <!--using LevelMenuItemStyles.   -->
         <!--Note that each menu item style represents a level
 in the menu -->

      <asp:Menu id="MainMenuID"
       Font-Names= "Arial"
        ForeColor="Blue"
        runat="server">
         
         <LevelMenuItemStyles>
         <asp:MenuItemStyle BackColor="Azure" 
             Font-Italic="true"
             Font-Names="Arial"
             ForeColor="Black" />
         
           <asp:MenuItemStyle BackColor="Black"
 
             Font-Italic="false"
             Font-Names="Arial"
             ForeColor="White" />
             
         <asp:MenuItemStyle BackColor="Green" 
             Font-Italic="true"
             Font-Names="Arial"
             ForeColor="Yellow" />
       
         </LevelMenuItemStyles>

        <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)
    {

      // Use the Add and RemoveAt methods to programmatically 
      // remove the third level menu item style and replace 
      // it with a new style, in this case replacing the green background
        // and yellow text with the blue background and white text.
 

        MenuItemStyle newStyle = new MenuItemStyle();
        newStyle.BackColor = System.Drawing.Color.Blue;
        newStyle.ForeColor = System.Drawing.Color.White;

        // Remove the last of the three menu item styles. Note that
        // since the collection has a zero-based index, the third
        // entry has an index value of 2.
        MainMenuID.LevelMenuItemStyles.RemoveAt(2);
        MainMenuID.LevelMenuItemStyles.Add(newStyle);

    }

  }

</script>

<html>
  <body>
    <form runat="server">
    
      <h3>MenuItemStyleCollection Example</h3>
         <!--Add MenuItemStyle objects to the MenuItemStyleCollection -->
         <!--using LevelMenuItemStyles.  -->
         <!--Note that each menu item style represents a level in
 the menu -->

      <asp:Menu id="MainMenuID"
       Font-Names= "Arial"
        ForeColor="Blue"
        runat="server">
         
         <LevelMenuItemStyles>
         <asp:MenuItemStyle BackColor="Azure" 
             Font-Italic="true"
             Font-Names="Arial"
             ForeColor="Black" />
         
           <asp:MenuItemStyle BackColor="Black" 
             Font-Italic="false"
             Font-Names="Arial"
             ForeColor="White" />
             
         <asp:MenuItemStyle BackColor="Green" 
             Font-Italic="true"
             Font-Names="Arial"
             ForeColor="Yellow" />
       
         </LevelMenuItemStyles>

        <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>

.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.Web.UI.StateManagedCollection
    System.Web.UI.WebControls.MenuItemStyleCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MenuItemStyleCollection メンバ
System.Web.UI.WebControls 名前空間
Menu クラス
MenuItem クラス
MenuItemStyle クラス
StyleCollection
SubMenuStyle
SubMenuStyleCollection
Menu.LevelMenuItemStyles プロパティ
Menu.LevelSelectedStyles プロパティ

MenuItemStyleCollection プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Count  StateManagedCollection コレクション格納されている要素の数を取得します。 ( StateManagedCollection から継承されます。)
パブリック プロパティ Item 指定したインデックス位置にある MenuItemStyle オブジェクトコレクションから取得します
参照参照

関連項目

MenuItemStyleCollection クラス
System.Web.UI.WebControls 名前空間
Menu クラス
MenuItem クラス
MenuItemStyle クラス
StyleCollection
SubMenuStyle
SubMenuStyleCollection
Menu.LevelMenuItemStyles プロパティ
Menu.LevelSelectedStyles プロパティ

MenuItemStyleCollection メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Add 指定した MenuItemStyle オブジェクト現在のコレクション末尾追加します
パブリック メソッド Clear  StateManagedCollection コレクションからすべての項目を削除します。 ( StateManagedCollection から継承されます。)
パブリック メソッド Contains 指定した MenuItemStyle オブジェクトコレクション内にあるかどうか確認します
パブリック メソッド CopyTo オーバーロードされます。 MenuItemStyleCollection オブジェクトからすべての項目をコピーします
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド GetEnumerator  StateManagedCollection コレクション反復処理する反復子返します。 ( StateManagedCollection から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド IndexOf コレクション内の指定した MenuItemStyle オブジェクトインデックス確認します
パブリック メソッド Insert このコレクション内の指定したインデックス位置に、指定した MenuItemStyle オブジェクト挿入します
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド Remove 指定した MenuItemStyle オブジェクトコレクションから削除します
パブリック メソッド RemoveAt 指定したインデックス位置にある MenuItemStyle オブジェクトコレクションから削除します
パブリック メソッド SetDirty  強制的に StateManagedCollection コレクション全体ビューステートシリアル化ます。 ( StateManagedCollection から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

MenuItemStyleCollection クラス
System.Web.UI.WebControls 名前空間
Menu クラス
MenuItem クラス
MenuItemStyle クラス
StyleCollection
SubMenuStyle
SubMenuStyleCollection
Menu.LevelMenuItemStyles プロパティ
Menu.LevelSelectedStyles プロパティ

MenuItemStyleCollection メンバ

Menu コントロール内の MenuItemStyle オブジェクトコレクション表します。このクラス継承できません。

MenuItemStyleCollection データ型公開されるメンバを以下の表に示します


パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Count  StateManagedCollection コレクション格納されている要素の数を取得します。(StateManagedCollection から継承されます。)
パブリック プロパティ Item 指定したインデックス位置にある MenuItemStyle オブジェクトコレクションから取得します
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Add 指定した MenuItemStyle オブジェクト現在のコレクション末尾追加します
パブリック メソッド Clear  StateManagedCollection コレクションからすべての項目を削除します。 (StateManagedCollection から継承されます。)
パブリック メソッド Contains 指定した MenuItemStyle オブジェクトコレクション内にあるかどうか確認します
パブリック メソッド CopyTo オーバーロードされます。 MenuItemStyleCollection オブジェクトからすべての項目をコピーします
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド GetEnumerator  StateManagedCollection コレクション反復処理する反復子返します。 (StateManagedCollection から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド IndexOf コレクション内の指定した MenuItemStyle オブジェクトインデックス確認します
パブリック メソッド Insert このコレクション内の指定したインデックス位置に、指定した MenuItemStyle オブジェクト挿入します
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド Remove 指定した MenuItemStyle オブジェクトコレクションから削除します
パブリック メソッド RemoveAt 指定したインデックス位置にある MenuItemStyle オブジェクトコレクションから削除します
パブリック メソッド SetDirty  強制的に StateManagedCollection コレクション全体ビューステートシリアル化ます。 (StateManagedCollection から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

MenuItemStyleCollection クラス
System.Web.UI.WebControls 名前空間
Menu クラス
MenuItem クラス
MenuItemStyle クラス
StyleCollection
SubMenuStyle
SubMenuStyleCollection
Menu.LevelMenuItemStyles プロパティ
Menu.LevelSelectedStyles プロパティ


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

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

辞書ショートカット

すべての辞書の索引

「MenuItemStyleCollection」の関連用語

MenuItemStyleCollectionのお隣キーワード
検索ランキング

   

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



MenuItemStyleCollectionのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS