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

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > 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 プロパティ



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

辞書ショートカット

すべての辞書の索引

「MenuItemStyleCollection クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS