Suggérer une traduction
 
Suggestions d'autres utilisateurs :

progress indicator
Aucune autre suggestion.
Cliquez pour évaluer et commenter
MSDN
MSDN Library
Développement .NET
.NET Framework 4
Espaces de noms System.Web
System.Web.UI.WebControls
Réduire tout/Développer tout Réduire tout
Affichage du contenu :  côte à côteAffichage du contenu : côte à côte
.NET Framework Class Library
MenuItemStyleCollection Class

Represents a collection of MenuItemStyle objects in a Menu control. This class cannot be inherited.

System..::.Object
  System.Web.UI..::.StateManagedCollection
    System.Web.UI.WebControls..::.MenuItemStyleCollection

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
Visual Basic
Public NotInheritable Class MenuItemStyleCollection _
    Inherits StateManagedCollection
C#
public sealed class MenuItemStyleCollection : StateManagedCollection
Visual C++
public ref class MenuItemStyleCollection sealed : public StateManagedCollection
F#
[<Sealed>]
type MenuItemStyleCollection =  
    class
        inherit StateManagedCollection
    end

The MenuItemStyleCollection type exposes the following members.

  NameDescription
Public propertyCountGets the number of elements contained in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public propertyItemGets the MenuItemStyle object at the specified index from the collection.
Top
  NameDescription
Public methodAddAppends the specified MenuItemStyle object to the end of the current collection.
Public methodClearRemoves all items from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public methodContainsDetermines whether the specified MenuItemStyle object is in the collection.
Public methodCopyTo(Array, Int32)Copies the elements of the StateManagedCollection collection to an array, starting at a particular array index. (Inherited from StateManagedCollection.)
Public methodCopyTo(array<MenuItemStyle>[]()[], Int32)Copies all the items from the MenuItemStyleCollection object to a compatible one-dimensional array of MenuItemStyle objects, starting at the specified index in the target array.
Protected methodCreateKnownTypeWhen overridden in a derived class, creates an instance of a class that implements IStateManager. The type of object created is based on the specified member of the collection returned by the GetKnownTypes method. (Inherited from StateManagedCollection.)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnumeratorReturns an iterator that iterates through the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Protected methodGetKnownTypesWhen overridden in a derived class, gets an array of IStateManager types that the StateManagedCollection collection can contain. (Inherited from StateManagedCollection.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIndexOfDetermines the index of the specified MenuItemStyle object in the collection.
Public methodInsertInserts the specified MenuItemStyle object into the collection at the specified index location.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnClearWhen overridden in a derived class, performs additional work before the Clear method removes all items from the collection. (Inherited from StateManagedCollection.)
Protected methodOnClearCompleteWhen overridden in a derived class, performs additional work after the Clear method finishes removing all items from the collection. (Inherited from StateManagedCollection.)
Protected methodOnInsertWhen overridden in a derived class, performs additional work before the Insert(Int32, Object) or Add(Object) method adds an item to the collection. (Inherited from StateManagedCollection.)
Protected methodOnInsertCompleteWhen 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.)
Protected methodOnRemoveWhen 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.)
Protected methodOnRemoveCompleteWhen 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.)
Protected methodOnValidateWhen overridden in a derived class, validates an element of the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public methodRemoveRemoves the specified MenuItemStyle object from the collection.
Public methodRemoveAtRemoves the MenuItemStyle object at the specified index location from the collection.
Public methodSetDirtyForces the entire StateManagedCollection collection to be serialized into view state. (Inherited from StateManagedCollection.)
Protected methodSetDirtyObjectWhen overridden in a derived class, instructs an object contained by the collection to record its entire state to view state, rather than recording only change information. (Inherited from StateManagedCollection.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top
  NameDescription
Explicit interface implemetationPrivate propertyICollection..::.CountInfrastructure. Gets the number of elements contained in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyICollection..::.IsSynchronizedInfrastructure. Gets a value indicating whether the StateManagedCollection collection is synchronized (thread safe). This method returns false in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyICollection..::.SyncRootInfrastructure. Gets an object that can be used to synchronize access to the StateManagedCollection collection. This method returns nullNothingnullptra null reference (Nothing in Visual Basic) in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIEnumerable..::.GetEnumeratorInfrastructure. Returns an iterator that iterates through the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList..::.AddAdds an item to the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList..::.ClearInfrastructure. Removes all items from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList..::.ContainsDetermines whether the StateManagedCollection collection contains a specific value. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList..::.IndexOfDetermines the index of a specified item in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList..::.InsertInserts an item into the StateManagedCollection collection at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList..::.IsFixedSizeInfrastructure. Gets a value indicating whether the StateManagedCollection collection has a fixed size. This method returns false in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList..::.IsReadOnlyInfrastructure. Gets a value indicating whether the StateManagedCollection collection is read-only. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList..::.ItemInfrastructure. Gets the IStateManager element at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList..::.RemoveRemoves the first occurrence of the specified object from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList..::.RemoveAtRemoves the IStateManager element at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIStateManager..::.IsTrackingViewStateGets a value indicating whether the StateManagedCollection collection is saving changes to its view state. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager..::.LoadViewStateRestores the previously saved view state of the StateManagedCollection collection and the IStateManager items it contains. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager..::.SaveViewStateSaves the changes to the StateManagedCollection collection and each IStateManager object it contains since the time the page was posted back to the server. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager..::.TrackViewStateCauses the StateManagedCollection collection and each of the IStateManager objects it contains to track changes to their view state so they can be persisted across requests for the same page. (Inherited from StateManagedCollection.)
Top

The MenuItemStyleCollection class is used to store and manage a collection of MenuItemStyle objects in a Menu control. The Menu control uses the MenuItemStyleCollection class as the underlying data type of the LevelMenuItemStyles and LevelSelectedStyles properties.

The LevelMenuItemStyles and LevelSelectedStyles properties are an alternative to the individual style properties (such as StaticMenuItemStyle). These properties are applied to regular menu items and the selected menu item, respectively, based on the menu item's level in the menu. The first style in the collection corresponds to the menu item style for the first level of the menu. The second style in the collection corresponds to the menu item style for the second level of the menu, and so on. The LevelMenuItemStyles and LevelSelectedStyles properties are most often used to generate menus where menu items at a certain level have the same appearance, regardless of whether they have submenus.

The MenuItemStyleCollection class inherits most of its members from the StateManagedCollection class. For more information on the inherited members, see StateManagedCollection.

The following code example demonstrates how to use the MenuItemStyleCollection class to specify the style settings for the menu items in a Menu control based on the menu item's level. In this example, the LevelMenuItemStyles property is created declaratively, and one MenuItemStyle object is removed and another added to the MenuItemStyleCollection object.

Visual Basic

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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  >
  <head runat="server">
    <title>MenuItemStyleCollection Example</title>
</head>
<body>
    <form id="form1" 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>

C#

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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  >
  <head runat="server">
    <title>MenuItemStyleCollection Example</title>
</head>
<body>
    <form id="form1" 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

Supported in: 4, 3.5, 3.0, 2.0

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.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Bibliothèque de classes .NET Framework
MenuItemStyleCollection, classe

Représente une collection d'objets MenuItemStyle dans un contrôle Menu. Cette classe ne peut pas être héritée.

System..::.Object
  System.Web.UI..::.StateManagedCollection
    System.Web.UI.WebControls..::.MenuItemStyleCollection

Espace de noms :  System.Web.UI.WebControls
Assembly :  System.Web (dans System.Web.dll)
Visual Basic
Public NotInheritable Class MenuItemStyleCollection _
    Inherits StateManagedCollection
C#
public sealed class MenuItemStyleCollection : StateManagedCollection
VisualC++
public ref class MenuItemStyleCollection sealed : public StateManagedCollection
F#
[<Sealed>]
type MenuItemStyleCollection =  
    class
        inherit StateManagedCollection
    end

Le type MenuItemStyleCollection expose les membres suivants.

  NomDescription
Propriété publiqueCountObtient le nombre d'éléments contenus dans la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Propriété publiqueItemObtient l'objet MenuItemStyle situé à l'index spécifié de la collection.
Début
  NomDescription
Méthode publiqueAddAjoute l'objet MenuItemStyle spécifié à la fin de la collection en cours.
Méthode publiqueClearSupprime tous les éléments de la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Méthode publiqueContainsDétermine si l'objet MenuItemStyle spécifié se trouve dans la collection.
Méthode publiqueCopyTo(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.)
Méthode publiqueCopyTo(array<MenuItemStyle>[]()[], Int32)Copie tous les éléments de l'objet MenuItemStyleCollection dans un tableau d'objets MenuItemStyle compatible unidimensionnel, en commençant à l'index spécifié dans le tableau cible.
Méthode protégéeCreateKnownTypeEn cas de substitution dans une classe dérivée, crée une instance d'une classe qui implémente IStateManager. Le type d'objet créé repose sur le membre spécifié de la collection retournée par la méthode GetKnownTypes. (Hérité de StateManagedCollection.)
Méthode publiqueEquals(Object)Détermine si l'Object spécifié est égal à l'Object en cours. (Hérité de Object.)
Méthode protégéeFinalizeAutorise 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.)
Méthode publiqueGetEnumeratorRetourne un itérateur qui itère au sein de la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Méthode publiqueGetHashCodeSert de fonction de hachage pour un type particulier. (Hérité de Object.)
Méthode protégéeGetKnownTypesEn cas de substitution dans une classe dérivée, obtient un tableau de types IStateManager que la collection StateManagedCollection peut contenir. (Hérité de StateManagedCollection.)
Méthode publiqueGetTypeObtient le Type de l'instance actuelle. (Hérité de Object.)
Méthode publiqueIndexOfDétermine l'index de l'objet MenuItemStyle spécifié dans la collection.
Méthode publiqueInsertInsère l'objet MenuItemStyle spécifié dans la collection à la position d'index spécifiée.
Méthode protégéeMemberwiseCloneCrée une copie superficielle de l'objet Object actif. (Hérité de Object.)
Méthode protégéeOnClearEn 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.)
Méthode protégéeOnClearCompleteEn 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.)
Méthode protégéeOnInsertEn cas de substitution dans une classe dérivée, exécute une tâche supplémentaire avant la méthode Insert(Int32, Object) ou Add(Object) ajoute un élément à la collection. (Hérité de StateManagedCollection.)
Méthode protégéeOnInsertCompleteEn 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.)
Méthode protégéeOnRemoveEn 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.)
Méthode protégéeOnRemoveCompleteEn 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.)
Méthode protégéeOnValidateEn cas de substitution dans une classe dérivée, valide un élément de la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Méthode publiqueRemoveSupprime de la collection l'objet MenuItemStyle spécifié.
Méthode publiqueRemoveAtSupprime de la collection l'objet MenuItemStyle situé à la position d'index spécifiée.
Méthode publiqueSetDirtyForce la sérialisation de l'intégralité de la collection StateManagedCollection dans l'état d'affichage. (Hérité de StateManagedCollection.)
Méthode protégéeSetDirtyObjectEn cas de substitution dans une classe dérivée, commande à un object contenu dans la collection d'enregistrer l'intégralité de son état dans l'état d'affichage, plutôt que d'enregistrer uniquement des informations relatives aux modifications. (Hérité de StateManagedCollection.)
Méthode publiqueToStringRetourne une chaîne qui représente l'objet actuel. (Hérité de Object.)
Début
  NomDescription
Implémentation d'interface explicitePropriété privéeICollection..::.CountInfrastructure. Obtient le nombre d'éléments contenus dans la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Implémentation d'interface explicitePropriété privéeICollection..::.IsSynchronizedInfrastructure. Obtient une valeur indiquant si la collection StateManagedCollection est synchronisée (thread-safe). Cette méthode retourne false dans tous les cas. (Hérité de StateManagedCollection.)
Implémentation d'interface explicitePropriété privéeICollection..::.SyncRootInfrastructure. Obtient un objet qui peut être utilisé pour synchroniser l'accès à la collection StateManagedCollection. Cette méthode retourne nullNothingnullptrune référence null (Nothing en Visual Basic) dans tous les cas. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIEnumerable..::.GetEnumeratorInfrastructure. Retourne un itérateur qui itère au sein de la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIList..::.AddAjoute un élément à la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIList..::.ClearInfrastructure. Supprime tous les éléments de la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIList..::.ContainsDétermine si la collection StateManagedCollection contient une valeur spécifique. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIList..::.IndexOfDétermine l'index d'un élément spécifié de la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIList..::.InsertInsère un élément dans la collection StateManagedCollection à l'index spécifié. (Hérité de StateManagedCollection.)
Implémentation d'interface explicitePropriété privéeIList..::.IsFixedSizeInfrastructure. Obtient une valeur indiquant si la collection StateManagedCollection est de taille fixe. Cette méthode retourne false dans tous les cas. (Hérité de StateManagedCollection.)
Implémentation d'interface explicitePropriété privéeIList..::.IsReadOnlyInfrastructure. Obtient une valeur indiquant si la collection StateManagedCollection est en lecture seule. (Hérité de StateManagedCollection.)
Implémentation d'interface explicitePropriété privéeIList..::.ItemInfrastructure. Obtient l'élément IStateManager à l'index spécifié. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIList..::.RemoveSupprime la première occurrence de l'objet spécifié dans la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIList..::.RemoveAtSupprime l'élément IStateManager au niveau de l'index spécifié. (Hérité de StateManagedCollection.)
Implémentation d'interface explicitePropriété privéeIStateManager..::.IsTrackingViewStateObtient une valeur indiquant si la collection StateManagedCollection enregistre les modifications apportées à son état d'affichage. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIStateManager..::.LoadViewStateRestaure l'état d'affichage précédemment enregistré de la collection StateManagedCollection et les éléments IStateManager qu'elle contient. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIStateManager..::.SaveViewStateEnregistre les modifications apportées à la collection StateManagedCollection et à chaque objet IStateManager qu'elle contient, depuis la publication de la page sur le serveur. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIStateManager..::.TrackViewStateCommande à la collection StateManagedCollection et à chacun des objets IStateManager qu'elle contient de procéder au suivi des modifications apportées à leur état d'affichage afin qu'ils puissent être rendus persistants au fil des requêtes d'une même page. (Hérité de StateManagedCollection.)
Début

La classe MenuItemStyleCollection est utilisée pour stocker et gérer une collection d'objets MenuItemStyle dans un contrôle Menu. Le contrôle Menu utilise la classe MenuItemStyleCollection comme type de données sous-jacent des propriétés LevelMenuItemStyles et LevelSelectedStyles.

Les propriétés LevelMenuItemStyles et LevelSelectedStyles sont une alternative aux propriétés de style (telles que StaticMenuItemStyle). Ces propriétés sont respectivement appliquées à des éléments de menu normaux et à l'élément de menu sélectionné en fonction du niveau de l'élément de menu dans le menu. Le premier style de la collection correspond au style d'élément de menu du premier niveau du menu. Le deuxième style de la collection correspond au style d'élément de menu du deuxième niveau du menu, et ainsi de suite. Les propriétés LevelMenuItemStyles et LevelSelectedStyles sont plus souvent utilisées pour générer des menus dans lesquels les éléments de menu à un certain niveau ont la même apparence, qu'ils comportent ou non des sous-menus.

La classe MenuItemStyleCollection hérite la plupart de ses membres de la classe StateManagedCollection. Pour plus d'informations sur les membres hérités, consultez StateManagedCollection.

L'exemple de code suivant montre comment utiliser la classe MenuItemStyleCollection pour spécifier les paramètres de style pour les éléments de menu dans un contrôle Menu en fonction du niveau de l'élément de menu. Dans cet exemple, la propriété LevelMenuItemStyles est créée de manière déclarative, un objet MenuItemStyle est supprimé et un autre est ajouté à l'objet MenuItemStyleCollection.

Visual Basic

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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  >
  <head runat="server">
    <title>MenuItemStyleCollection Example</title>
</head>
<body>
    <form id="form1" 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>

C#

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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  >
  <head runat="server">
    <title>MenuItemStyleCollection Example</title>
</head>
<body>
    <form id="form1" 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

Pris en charge dans : 4, 3.5, 3.0, 2.0

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.
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.
Contenu de la communauté   Qu'est-ce que le Contenu de la communauté ?
Ajouter du contenu RSS  Annotations
Processing
© 2012 Microsoft. Tous droits réservés. Conditions d'utilisation | Marques | Confidentialité
Page view tracker