.NET Framework Class Library SubMenuStyleCollection Class

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

Syntax
Public Class SubMenuStyleCollection _
Inherits StateManagedCollection
public class SubMenuStyleCollection : StateManagedCollection
public ref class SubMenuStyleCollection : public StateManagedCollection
type SubMenuStyleCollection =
class
inherit StateManagedCollection
end
The SubMenuStyleCollection type exposes the following members.

Properties

Methods
|
| Name | Description |
|---|
.gif) | Add | Adds a submenu style to the SubMenuStyleCollection collection. | .gif) | Clear | Removes all items from the StateManagedCollection collection. (Inherited from StateManagedCollection.) | .gif) | Contains | Determines whether a SubMenuStyleCollection collection contains a specific SubMenuStyle instance. | .gif) | CopyTo(Array, Int32) | Copies the elements of the StateManagedCollection collection to an array, starting at a particular array index. (Inherited from StateManagedCollection.) | .gif) | CopyTo(array<SubMenuStyle>[]()[], Int32) | Copies the contents of a SubMenuStyleCollection collection to an array, starting at a specified array index. | .gif) | CreateKnownType | Creates an System..::.Object of the data type that corresponds to the specified index. (Overrides StateManagedCollection..::.CreateKnownType(Int32).) | .gif) | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | .gif) | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | .gif) | GetEnumerator | Returns an iterator that iterates through the StateManagedCollection collection. (Inherited from StateManagedCollection.) | .gif) | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | .gif) | GetKnownTypes | Creates an array of System..::.Type objects that contains the supported data types of the SubMenuStyleCollection class. (Overrides StateManagedCollection..::.GetKnownTypes()()().) | .gif) | GetType | Gets the Type of the current instance. (Inherited from Object.) | .gif) | IndexOf | Determines the location of a specified SubMenuStyle object in the SubMenuStyleCollection collection. | .gif) | Insert | Inserts a SubMenuStyle object into the SubMenuStyleCollection collection at the specified index. | .gif) | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | .gif) | OnClear | When overridden in a derived class, performs additional work before the Clear method removes all items from the collection. (Inherited from StateManagedCollection.) | .gif) | OnClearComplete | When overridden in a derived class, performs additional work after the Clear method finishes removing all items from the collection. (Inherited from StateManagedCollection.) | .gif) | OnInsert | Called before the Add and Insert methods. (Overrides StateManagedCollection..::.OnInsert(Int32, Object).) | .gif) | OnInsertComplete | When overridden in a derived class, performs additional work after the Insert(Int32, Object) or Add(Object) method adds an item to the collection. (Inherited from StateManagedCollection.) | .gif) | OnRemove | When overridden in a derived class, performs additional work before the Remove(Object) or RemoveAt(Int32) method removes the specified item from the collection. (Inherited from StateManagedCollection.) | .gif) | OnRemoveComplete | When overridden in a derived class, performs additional work after the Remove(Object) or RemoveAt(Int32) method removes the specified item from the collection. (Inherited from StateManagedCollection.) | .gif) | OnValidate | When overridden in a derived class, validates an element of the StateManagedCollection collection. (Inherited from StateManagedCollection.) | .gif) | Remove | Removes the first occurrence of the specified SubMenuStyle object from the SubMenuStyleCollection collection. | .gif) | RemoveAt | Removes the SubMenuStyle object at the specified location. | .gif) | SetDirty | Forces the entire StateManagedCollection collection to be serialized into view state. (Inherited from StateManagedCollection.) | .gif) | SetDirtyObject | Instructs a SubMenuStyle object contained by the SubMenuStyleCollection collection to record its entire state to view state. (Overrides StateManagedCollection..::.SetDirtyObject(Object).) | .gif) | ToString | Returns a string that represents the current object. (Inherited from Object.) | Top

Explicit Interface Implementations

Remarks
The SubMenuStyleCollection class is used to store and manage a collection of SubMenuStyle objects in a Menu control. The Menu control uses the SubMenuStyleCollection class as the underlying data type of the LevelSubMenuStyles property. The LevelSubMenuStyles property provides additional style choices in addition to the StaticMenuStyle and DynamicMenuStyle properties. The first style in the SubMenuStyleCollection collection corresponds to the submenu style for the first level of the menu. The second style in the collection corresponds to the submenu style for the second level of the menu, and so on. The LevelSubMenuStyles property is most often used to generate a navigation menu, like a Web site map, where menu items at a certain level should have the same appearance, regardless of whether they have submenus. The SubMenuStyleCollection class inherits most of its members from the StateManagedCollection class. For more information on the inherited members, see the StateManagedCollection collection.

Examples
The following example demonstrates how to use the SubMenuStyleCollection class to specify the style settings for the submenus in a Menu control based on the submenu's level. In this example, the LevelSubMenuStyles property returns a SubMenuStyleCollection object.
<%@ 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 LevelSubMenuStyles</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu LevelSubMenuStyles</h3>
<asp:menu id="NavigationMenu"
staticdisplaylevels="3"
staticsubmenuindent="10"
orientation="Vertical"
target="_blank"
runat="server">
<levelsubmenustyles>
<asp:submenustyle backcolor="LightSteelBlue"
forecolor="Black"/>
<asp:submenustyle backcolor="SkyBlue"
forecolor="Gray"/>
</levelsubmenustyles>
<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#" %>
<!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 LevelSubMenuStyles</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu LevelSubMenuStyles</h3>
<asp:menu id="NavigationMenu"
staticdisplaylevels="3"
staticsubmenuindent="10"
orientation="Vertical"
target="_blank"
runat="server">
<levelsubmenustyles>
<asp:submenustyle backcolor="LightSteelBlue"
forecolor="Black"/>
<asp:submenustyle backcolor="SkyBlue"
forecolor="Gray"/>
</levelsubmenustyles>
<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>

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 SubMenuStyleCollection, classe

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

Syntaxe
Public Class SubMenuStyleCollection _
Inherits StateManagedCollection
public class SubMenuStyleCollection : StateManagedCollection
public ref class SubMenuStyleCollection : public StateManagedCollection
type SubMenuStyleCollection =
class
inherit StateManagedCollection
end
Le type SubMenuStyleCollection expose les membres suivants.

Propriétés

Méthodes
|
| Nom | Description |
|---|
.gif) | Add | Ajoute un style de sous-menu à la collection SubMenuStyleCollection. | .gif) | Clear | Supprime tous les éléments de la collection StateManagedCollection. (Hérité de StateManagedCollection.) | .gif) | Contains | Détermine si une collection SubMenuStyleCollection contient une instance de SubMenuStyle spécifique. | .gif) | CopyTo(Array, Int32) | Copie les éléments de la collection StateManagedCollection dans un tableau, en commençant au niveau d'un index de tableau particulier. (Hérité de StateManagedCollection.) | .gif) | CopyTo(array<SubMenuStyle>[]()[], Int32) | Copie le contenu d'une collection SubMenuStyleCollection dans un tableau, en commençant à un index de tableau spécifié. | .gif) | CreateKnownType | Crée un System..::.Object du type de données qui correspond à l'index spécifié. (Substitue StateManagedCollection..::.CreateKnownType(Int32).) | .gif) | Equals(Object) | Détermine si l'Object spécifié est égal à l'Object en cours. (Hérité de Object.) | .gif) | Finalize | Autorise un objet à tenter de libérer des ressources et d'exécuter d'autres opérations de netto***ge avant qu'il ne soit récupéré par l'opération garbage collection. (Hérité de Object.) | .gif) | GetEnumerator | Retourne un itérateur qui itère au sein de la collection StateManagedCollection. (Hérité de StateManagedCollection.) | .gif) | GetHashCode | Sert de fonction de hachage pour un type particulier. (Hérité de Object.) | .gif) | GetKnownTypes | Crée un tableau d'objets System..::.Type qui contient les types de données pris en charge de la classe SubMenuStyleCollection. (Substitue StateManagedCollection..::.GetKnownTypes()()().) | .gif) | GetType | Obtient le Type de l'instance actuelle. (Hérité de Object.) | .gif) | IndexOf | Détermine l'emplacement d'un objet SubMenuStyle spécifié dans la collection SubMenuStyleCollection. | .gif) | Insert | Insère un objet SubMenuStyle dans la collection SubMenuStyleCollection à l'index spécifié. | .gif) | MemberwiseClone | Crée une copie superficielle de l'objet Object actif. (Hérité de Object.) | .gif) | OnClear | En cas de substitution dans une classe dérivée, exécute une tâche supplémentaire avant que la méthode Clear supprime tous les éléments de la collection. (Hérité de StateManagedCollection.) | .gif) | OnClearComplete | En cas de substitution dans une classe dérivée, exécute une tâche supplémentaire une fois tous les éléments de la collection supprimés par la méthode Clear. (Hérité de StateManagedCollection.) | .gif) | OnInsert | Appelé avant les méthodes Add et Insert. (Substitue StateManagedCollection..::.OnInsert(Int32, Object).) | .gif) | OnInsertComplete | En cas de substitution dans une classe dérivée, exécute une tâche supplémentaire après que la méthode Insert(Int32, Object) ou Add(Object) a ajouté un élément à la collection. (Hérité de StateManagedCollection.) | .gif) | OnRemove | En cas de substitution dans une classe dérivée, exécute toute tâche supplémentaire avant que la méthode Remove(Object) ou RemoveAt(Int32) supprime l'élément spécifié de la collection. (Hérité de StateManagedCollection.) | .gif) | OnRemoveComplete | En cas de substitution dans une classe dérivée, exécute toute tâche supplémentaire après que la méthode Remove(Object) ou RemoveAt(Int32) a supprimé l'élément spécifié de la collection. (Hérité de StateManagedCollection.) | .gif) | OnValidate | En cas de substitution dans une classe dérivée, valide un élément de la collection StateManagedCollection. (Hérité de StateManagedCollection.) | .gif) | Remove | Supprime de la collection SubMenuStyleCollection la première occurrence de l'objet SubMenuStyle spécifié. | .gif) | RemoveAt | Supprime l'objet SubMenuStyle à l'emplacement spécifié. | .gif) | SetDirty | Force la sérialisation de l'intégralité de la collection StateManagedCollection dans l'état d'affichage. (Hérité de StateManagedCollection.) | .gif) | SetDirtyObject | Instruit un objet SubMenuStyle contenu par la collection SubMenuStyleCollection pour enregistrer son état entier à l'état d'affichage. (Substitue StateManagedCollection..::.SetDirtyObject(Object).) | .gif) | ToString | Retourne une chaîne qui représente l'objet actuel. (Hérité de Object.) | Début

Implémentations d'interface explicite

Notes
La classe SubMenuStyleCollection est utilisée pour stocker et gérer une collection d'objets SubMenuStyle dans un contrôle Menu. Le contrôle Menu utilise la classe SubMenuStyleCollection comme type de données sous-jacent de la propriété LevelSubMenuStyles. La propriété LevelSubMenuStyles fournit des choix de style supplémentaires en plus des propriétés StaticMenuStyle et DynamicMenuStyle. Le premier style de la collection SubMenuStyleCollection correspond au style de sous-menu du premier niveau du menu. Le deuxième style de la collection correspond au style de sous-menu du deuxième niveau du menu, et ainsi de suite. La propriété LevelSubMenuStyles est le plus souvent utilisée pour générer un menu de navigation, par exemple un plan de site Web, où les éléments de menu, à un certain niveau, doivent avoir la même apparence, qu'ils aient ou non des sous-menus. La classe SubMenuStyleCollection hérite la plupart de ses membres de la classe StateManagedCollection. Pour plus d'informations sur les membres hérités, consultez la collection StateManagedCollection.

Exemples
L'exemple suivant montre comment utiliser la classe SubMenuStyleCollection pour spécifier les paramètres de style des sous-menus dans un contrôle Menu en fonction du niveau du sous-menu. Dans cet exemple, la propriété LevelSubMenuStyles retourne un objet SubMenuStyleCollection.
<%@ 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 LevelSubMenuStyles</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu LevelSubMenuStyles</h3>
<asp:menu id="NavigationMenu"
staticdisplaylevels="3"
staticsubmenuindent="10"
orientation="Vertical"
target="_blank"
runat="server">
<levelsubmenustyles>
<asp:submenustyle backcolor="LightSteelBlue"
forecolor="Black"/>
<asp:submenustyle backcolor="SkyBlue"
forecolor="Gray"/>
</levelsubmenustyles>
<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#" %>
<!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 LevelSubMenuStyles</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu LevelSubMenuStyles</h3>
<asp:menu id="NavigationMenu"
staticdisplaylevels="3"
staticsubmenuindent="10"
orientation="Vertical"
target="_blank"
runat="server">
<levelsubmenustyles>
<asp:submenustyle backcolor="LightSteelBlue"
forecolor="Black"/>
<asp:submenustyle backcolor="SkyBlue"
forecolor="Gray"/>
</levelsubmenustyles>
<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>

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
|