.NET Framework Class Library SubMenuStyle Class Represents the style of a submenu in a Menu control.

Inheritance Hierarchy
Namespace:
System.Web.UI.WebControls
Assembly:
System.Web (in System.Web.dll)

Syntax
Public Class SubMenuStyle _
Inherits Style _
Implements ICustomTypeDescriptor
public class SubMenuStyle : Style,
ICustomTypeDescriptor
public ref class SubMenuStyle : public Style,
ICustomTypeDescriptor
type SubMenuStyle =
class
inherit Style
interface ICustomTypeDescriptor
end
The SubMenuStyle type exposes the following members.

Constructors

Methods

Events

Explicit Interface Implementations
|
| Name | Description |
|---|
.gif) .gif) | ICustomTypeDescriptor..::.GetAttributes | For a description of this member, see ICustomTypeDescriptor..::.GetAttributes()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetClassName | For a description of this member, see ICustomTypeDescriptor..::.GetClassName()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetComponentName | For a description of this member, see ICustomTypeDescriptor..::.GetComponentName()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetConverter | For a description of this member, see ICustomTypeDescriptor..::.GetConverter()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetDefaultEvent | For a description of this member, see ICustomTypeDescriptor..::.GetDefaultEvent()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetDefaultProperty | For a description of this member, see ICustomTypeDescriptor..::.GetDefaultProperty()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetEditor | For a description of this member, see ICustomTypeDescriptor..::.GetEditor(Type). | .gif) .gif) | ICustomTypeDescriptor..::.GetEvents()()() | For a description of this member, see ICustomTypeDescriptor..::.GetEvents()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetEvents(array<Attribute>[]()[]) | For a description of this member, see ICustomTypeDescriptor..::.GetEvents(array<Attribute>[]()[]). | .gif) .gif) | ICustomTypeDescriptor..::.GetProperties()()() | For a description of this member, see ICustomTypeDescriptor..::.GetProperties()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetProperties(array<Attribute>[]()[]) | For a description of this member, see ICustomTypeDescriptor..::.GetProperties(array<Attribute>[]()[]). | .gif) .gif) | ICustomTypeDescriptor..::.GetPropertyOwner | For a description of this member, see ICustomTypeDescriptor..::.GetPropertyOwner(PropertyDescriptor). | .gif) .gif) | IStateManager..::.IsTrackingViewState | Gets a value that indicates whether a server control is tracking its view state changes. (Inherited from Style.) | .gif) .gif) | IStateManager..::.LoadViewState | Infrastructure. Loads the previously saved state. (Inherited from Style.) | .gif) .gif) | IStateManager..::.SaveViewState | Infrastructure. Returns the object containing state changes. (Inherited from Style.) | .gif) .gif) | IStateManager..::.TrackViewState | Infrastructure. Starts tracking state changes. (Inherited from Style.) | Top

Remarks
Use the SubMenuStyle class to represent the style of a submenu in the Menu control. A submenu can be displayed within either a static menu or a dynamic menu. A static menu is always visible on a Menu control, whereas a dynamic menu is displayed only when the user positions the mouse pointer over a parent menu item that contains a dynamic submenu. You can specify different style characteristics (such as font size and color) for the submenus within a static menu and a dynamic menu by using the properties in the following table. Submenu item style property | Description |
|---|
DynamicMenuStyle | The style settings for a submenu within a dynamic menu. | StaticMenuStyle | The style settings for a submenu within a static menu. |
The SubMenuStyle class inherits most of its members from the Style class. It extends the Style class by providing properties that control the amount of space around a menu item's text. Use the HorizontalPadding property to control the amount of space to the left and right of the menu item's text. Similarly, the VerticalPadding property controls the amount of space above and below the menu item's text. For more information on the inherited style settings, see Style. Note |
|---|
Set the z-index of HTML objects that are associated with a submenu by setting the CssClass property of the submenu style. The z-index attribute defines the stacking order of rendered HTML objects. By default, dynamic menu items will appear above any HTML object that has the default z-index (0). |

Examples
The following example demonstrates how to specify a custom style for a submenu within a dynamic menu.
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head runat="server">
<title>Menu DynamicMenuStyle Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu DynamicMenuStyle Example</h3>
<asp:menu id="NavigationMenu"
staticdisplaylevels="2"
staticsubmenuindent="10"
orientation="Vertical"
target="_blank"
runat="server">
<dynamicmenustyle backcolor="LightSkyBlue"
forecolor="Black"
borderstyle="Solid"
borderwidth="1"
bordercolor="Black" />
<items>
<asp:menuitem navigateurl="Home.aspx"
text="Home"
tooltip="Home">
<asp:menuitem navigateurl="Music.aspx"
text="Music"
tooltip="Music">
<asp:menuitem navigateurl="Classical.aspx"
text="Classical"
tooltip="Classical"/>
<asp:menuitem navigateurl="Rock.aspx"
text="Rock"
tooltip="Rock"/>
<asp:menuitem navigateurl="Jazz.aspx"
text="Jazz"
tooltip="Jazz"/>
</asp:menuitem>
<asp:menuitem navigateurl="Movies.aspx"
text="Movies"
tooltip="Movies">
<asp:menuitem navigateurl="Action.aspx"
text="Action"
tooltip="Action"/>
<asp:menuitem navigateurl="Drama.aspx"
text="Drama"
tooltip="Drama"/>
<asp:menuitem navigateurl="Musical.aspx"
text="Musical"
tooltip="Musical"/>
</asp:menuitem>
</asp:menuitem>
</items>
</asp:menu>
</form>
</body>
</html>
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head runat="server">
<title>Menu DynamicMenuStyle Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu DynamicMenuStyle Example</h3>
<asp:menu id="NavigationMenu"
staticdisplaylevels="2"
staticsubmenuindent="10"
orientation="Vertical"
target="_blank"
runat="server">
<dynamicmenustyle backcolor="LightSkyBlue"
forecolor="Black"
borderstyle="Solid"
borderwidth="1"
bordercolor="Black" />
<items>
<asp:menuitem navigateurl="Home.aspx"
text="Home"
tooltip="Home">
<asp:menuitem navigateurl="Music.aspx"
text="Music"
tooltip="Music">
<asp:menuitem navigateurl="Classical.aspx"
text="Classical"
tooltip="Classical"/>
<asp:menuitem navigateurl="Rock.aspx"
text="Rock"
tooltip="Rock"/>
<asp:menuitem navigateurl="Jazz.aspx"
text="Jazz"
tooltip="Jazz"/>
</asp:menuitem>
<asp:menuitem navigateurl="Movies.aspx"
text="Movies"
tooltip="Movies">
<asp:menuitem navigateurl="Action.aspx"
text="Action"
tooltip="Action"/>
<asp:menuitem navigateurl="Drama.aspx"
text="Drama"
tooltip="Drama"/>
<asp:menuitem navigateurl="Musical.aspx"
text="Musical"
tooltip="Musical"/>
</asp:menuitem>
</asp:menuitem>
</items>
</asp:menu>
</form>
</body>
</html>

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also
|
Bibliothèque de classes .NET Framework SubMenuStyle, classe Représente le style d'un sous-menu d'un contrôle Menu.

Hiérarchie d'héritage
Espace de noms :
System.Web.UI.WebControls
Assembly :
System.Web (dans System.Web.dll)

Syntaxe
Public Class SubMenuStyle _
Inherits Style _
Implements ICustomTypeDescriptor
public class SubMenuStyle : Style,
ICustomTypeDescriptor
public ref class SubMenuStyle : public Style,
ICustomTypeDescriptor
type SubMenuStyle =
class
inherit Style
interface ICustomTypeDescriptor
end
Le type SubMenuStyle expose les membres suivants.

Méthodes

Événements

Implémentations d'interface explicite
|
| Nom | Description |
|---|
.gif) .gif) | ICustomTypeDescriptor..::.GetAttributes | Pour obtenir une description de ce membre, consultez ICustomTypeDescriptor..::.GetAttributes()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetClassName | Pour obtenir une description de ce membre, consultez ICustomTypeDescriptor..::.GetClassName()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetComponentName | Pour obtenir une description de ce membre, consultez ICustomTypeDescriptor..::.GetComponentName()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetConverter | Pour obtenir une description de ce membre, consultez ICustomTypeDescriptor..::.GetConverter()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetDefaultEvent | Pour obtenir une description de ce membre, consultez ICustomTypeDescriptor..::.GetDefaultEvent()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetDefaultProperty | Pour obtenir une description de ce membre, consultez ICustomTypeDescriptor..::.GetDefaultProperty()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetEditor | Pour obtenir une description de ce membre, consultez ICustomTypeDescriptor..::.GetEditor(Type). | .gif) .gif) | ICustomTypeDescriptor..::.GetEvents()()() | Pour obtenir une description de ce membre, consultez ICustomTypeDescriptor..::.GetEvents()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetEvents(array<Attribute>[]()[]) | Pour obtenir une description de ce membre, consultez ICustomTypeDescriptor..::.GetEvents(array<Attribute>[]()[]). | .gif) .gif) | ICustomTypeDescriptor..::.GetProperties()()() | Pour obtenir une description de ce membre, consultez ICustomTypeDescriptor..::.GetProperties()()(). | .gif) .gif) | ICustomTypeDescriptor..::.GetProperties(array<Attribute>[]()[]) | Pour obtenir une description de ce membre, consultez ICustomTypeDescriptor..::.GetProperties(array<Attribute>[]()[]). | .gif) .gif) | ICustomTypeDescriptor..::.GetPropertyOwner | Pour obtenir une description de ce membre, consultez ICustomTypeDescriptor..::.GetPropertyOwner(PropertyDescriptor). | .gif) .gif) | IStateManager..::.IsTrackingViewState | Obtient une valeur qui indique si un contrôle serveur effectue le suivi des modifications apportées à son état d'affichage. (Hérité de Style.) | .gif) .gif) | IStateManager..::.LoadViewState | Infrastructure. Charge l'état enregistré précédemment. (Hérité de Style.) | .gif) .gif) | IStateManager..::.SaveViewState | Infrastructure. Retourne l'objet contenant les modifications de l'état. (Hérité de Style.) | .gif) .gif) | IStateManager..::.TrackViewState | Infrastructure. Commence à suivre les modifications d'état. (Hérité de Style.) | Début

Notes
Utilisez la classe SubMenuStyle pour représenter le style d'un sous-menu dans le contrôle Menu. Un sous-menu peut être affiché soit dans un menu statique, soit dans un menu dynamique. Un menu statique est toujours visible dans un contrôle Menu, tandis qu'un menu dynamique ne s'affiche que lorsque l'utilisateur positionne le pointeur de la souris sur un élément de menu parent qui contient un sous-menu dynamique. Vous pouvez spécifier des caractéristiques de style différentes (par exemple taille de police et couleur) pour les sous-menus d'un menu statique et d'un menu dynamique en utilisant les propriétés du tableau suivant. Propriété de style d'élément de sous-menu | Description |
|---|
DynamicMenuStyle | Paramètres de style d'un sous-menu dans un menu dynamique. | StaticMenuStyle | Paramètres de style d'un sous-menu dans un menu statique. |
La classe SubMenuStyle hérite la plupart de ses membres de la classe Style. Elle étend la classe Style en fournissant des propriétés qui contrôlent la quantité d'espace autour du texte d'un élément de menu. Utilisez la propriété HorizontalPadding pour contrôler l'espace à gauche et à droit du texte de l'élément de menu. De même, la propriété VerticalPadding contrôle l'espace au-dessus et en dessous du texte de l'élément de menu. Pour plus d'informations sur les paramètres de style hérités, consultez Style. Remarque |
|---|
Définissez le z-index des objets HTML qui sont associés à un sous-menu en définissant la propriété CssClass du style de sous-menu. L'attribut z-index définit l'ordre de mise en pile des objets HTML rendus. Par défaut, les éléments de menu dynamiques apparaîtront au-dessus de tout objet HTML ayant le z-index par défaut (0). |

Exemples
L'exemple suivant montre comment spécifier un style personnalisé pour un sous-menu dans un menu dynamique.
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head runat="server">
<title>Menu DynamicMenuStyle Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu DynamicMenuStyle Example</h3>
<asp:menu id="NavigationMenu"
staticdisplaylevels="2"
staticsubmenuindent="10"
orientation="Vertical"
target="_blank"
runat="server">
<dynamicmenustyle backcolor="LightSkyBlue"
forecolor="Black"
borderstyle="Solid"
borderwidth="1"
bordercolor="Black" />
<items>
<asp:menuitem navigateurl="Home.aspx"
text="Home"
tooltip="Home">
<asp:menuitem navigateurl="Music.aspx"
text="Music"
tooltip="Music">
<asp:menuitem navigateurl="Classical.aspx"
text="Classical"
tooltip="Classical"/>
<asp:menuitem navigateurl="Rock.aspx"
text="Rock"
tooltip="Rock"/>
<asp:menuitem navigateurl="Jazz.aspx"
text="Jazz"
tooltip="Jazz"/>
</asp:menuitem>
<asp:menuitem navigateurl="Movies.aspx"
text="Movies"
tooltip="Movies">
<asp:menuitem navigateurl="Action.aspx"
text="Action"
tooltip="Action"/>
<asp:menuitem navigateurl="Drama.aspx"
text="Drama"
tooltip="Drama"/>
<asp:menuitem navigateurl="Musical.aspx"
text="Musical"
tooltip="Musical"/>
</asp:menuitem>
</asp:menuitem>
</items>
</asp:menu>
</form>
</body>
</html>
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head runat="server">
<title>Menu DynamicMenuStyle Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu DynamicMenuStyle Example</h3>
<asp:menu id="NavigationMenu"
staticdisplaylevels="2"
staticsubmenuindent="10"
orientation="Vertical"
target="_blank"
runat="server">
<dynamicmenustyle backcolor="LightSkyBlue"
forecolor="Black"
borderstyle="Solid"
borderwidth="1"
bordercolor="Black" />
<items>
<asp:menuitem navigateurl="Home.aspx"
text="Home"
tooltip="Home">
<asp:menuitem navigateurl="Music.aspx"
text="Music"
tooltip="Music">
<asp:menuitem navigateurl="Classical.aspx"
text="Classical"
tooltip="Classical"/>
<asp:menuitem navigateurl="Rock.aspx"
text="Rock"
tooltip="Rock"/>
<asp:menuitem navigateurl="Jazz.aspx"
text="Jazz"
tooltip="Jazz"/>
</asp:menuitem>
<asp:menuitem navigateurl="Movies.aspx"
text="Movies"
tooltip="Movies">
<asp:menuitem navigateurl="Action.aspx"
text="Action"
tooltip="Action"/>
<asp:menuitem navigateurl="Drama.aspx"
text="Drama"
tooltip="Drama"/>
<asp:menuitem navigateurl="Musical.aspx"
text="Musical"
tooltip="Musical"/>
</asp:menuitem>
</asp:menuitem>
</items>
</asp:menu>
</form>
</body>
</html>

Informations de version
.NET FrameworkPris en charge dans : 4, 3.5, 3.0, 2.0

Plateformes
Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

Sécurité des threads
Tous les membres static ( Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Voir aussi
|