Menu.LevelSelectedStyles プロパティ
アセンブリ: System.Web (system.web.dll 内)

Menu コントロール内でのメニュー項目のレベルに基づいて選択されたメニュー項目に適用されるスタイル設定を格納している MenuItemStyleCollection。

選択されたメニュー項目のスタイルをメニューのレベル別に制御するには、DynamicSelectedStyle プロパティおよび StaticSelectedStyle プロパティの代わりに LevelSelectedStyles コレクションを使用します。このコレクションに格納されているスタイルは、メニュー項目のメニュー レベルに基づいて選択されたメニュー項目に適用されます。このコレクションの中の最初のスタイルは、メニューの最初のレベルの選択されたメニュー項目のスタイルに対応します。このコレクションの中の 2 番目のスタイルは、メニューの 2 番目のレベルの選択されたメニュー項目のスタイルに対応し、以下同様に対応します。サブメニューの有無にかかわらず、一定のレベルにあるメニュー項目の外観を同じにする場合は、この方法でコンテンツ-スタイル ナビゲーション メニューのテーブルを生成するのが最も一般的です。
![]() |
---|
LevelSelectedStyles コレクションを使用してスタイルが一定のレベルに定義されている場合は、そのスタイル設定が、該当するレベルの DynamicSelectedStyle プロパティおよび StaticSelectedStyle プロパティをオーバーライドします。 |

LevelSelectedStyles コレクションを使用して、メニュー項目のレベルに基づいて Menu コントロールの選択されたメニュー項目にスタイル設定を適用する方法のコード例を次に示します。
<%@ Page Language="VB" %> <html> <body> <form runat="server"> <h3>Menu LevelMenuItemStyles and LevelSelectedStyles Example</h3> <asp:menu id="NavigationMenu" staticdisplaylevels="2" staticsubmenuindent="10" orientation="Vertical" target="_blank" runat="server"> <levelmenuitemstyles> <asp:menuitemstyle BackColor="LightSteelBlue" forecolor="Black"/> <asp:menuitemstyle BackColor="SkyBlue" forecolor="Black"/> <asp:menuitemstyle BackColor="LightSkyBlue" forecolor="Black"/> </levelmenuitemstyles> <levelselectedstyles> <asp:menuitemstyle BackColor="Cyan" forecolor="Gray"/> <asp:menuitemstyle BackColor="LightCyan" forecolor="Gray"/> <asp:menuitemstyle BackColor="PaleTurquoise" forecolor="Gray"/> </levelselectedstyles> <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#" %> <html> <body> <form runat="server"> <h3>Menu LevelMenuItemStyles and LevelSelectedStyles Example</h3> <asp:menu id="NavigationMenu" staticdisplaylevels="2" staticsubmenuindent="10" orientation="Vertical" target="_blank" runat="server"> <levelmenuitemstyles> <asp:menuitemstyle BackColor="LightSteelBlue" forecolor="Black"/> <asp:menuitemstyle BackColor="SkyBlue" forecolor="Black"/> <asp:menuitemstyle BackColor="LightSkyBlue" forecolor="Black"/> </levelmenuitemstyles> <levelselectedstyles> <asp:menuitemstyle BackColor="Cyan" forecolor="Gray"/> <asp:menuitemstyle BackColor="LightCyan" forecolor="Gray"/> <asp:menuitemstyle BackColor="PaleTurquoise" forecolor="Gray"/> </levelselectedstyles> <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に収録されているすべての辞書からMenu.LevelSelectedStyles プロパティを検索する場合は、下記のリンクをクリックしてください。

- Menu.LevelSelectedStyles プロパティのページへのリンク