MenuItemStyleCollection 클래스

정의

MenuItemStyle 컨트롤에 있는 Menu 개체의 컬렉션을 나타냅니다. 이 클래스는 상속될 수 없습니다.

public ref class MenuItemStyleCollection sealed : System::Web::UI::StateManagedCollection
public sealed class MenuItemStyleCollection : System.Web.UI.StateManagedCollection
type MenuItemStyleCollection = class
    inherit StateManagedCollection
Public NotInheritable Class MenuItemStyleCollection
Inherits StateManagedCollection
상속
MenuItemStyleCollection

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 MenuItemStyleCollection 클래스에서 메뉴 항목에 대 한 스타일 설정을 지정할 수를 Menu 제어 수준을 기준으로 메뉴 항목의 합니다. 이 예제에서는 합니다 LevelMenuItemStyles 속성은 선언적으로 만들어집니다 하나의 MenuItemStyle 개체가 제거 되 고 다른 추가 MenuItemStyleCollection 개체입니다.


<%@ 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 xmlns="http://www.w3.org/1999/xhtml" >
  <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>

<%@ 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 xmlns="http://www.w3.org/1999/xhtml" >
  <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>

설명

MenuItemStyleCollection 클래스를 저장 및 컬렉션을 관리 하는 데 사용 됩니다 MenuItemStyle 개체를 Menu 제어 합니다. 합니다 Menu 컨트롤이 사용 하는 MenuItemStyleCollection 클래스의 기본 데이터 형식으로는 LevelMenuItemStylesLevelSelectedStyles 속성입니다.

합니다 LevelMenuItemStyles 하 고 LevelSelectedStyles 속성은 개별 스타일 속성을 대신 (같은 StaticMenuItemStyle). 이러한 속성은 일반 메뉴 항목을 선택한 메뉴 항목을 각각 메뉴에서 메뉴 항목의 수준을 기준으로 합니다. 컬렉션의 첫 번째 스타일 메뉴의 첫 번째 수준에 대 한 메뉴 항목 스타일에 해당합니다. 컬렉션의 두 번째 스타일 메뉴 및 등의 두 번째 수준에 대 한 메뉴 항목 스타일에 해당합니다. 합니다 LevelMenuItemStylesLevelSelectedStyles 속성은 자주 사용 메뉴를 생성 하는 특정 수준에서 메뉴 항목의 하위 메뉴가 있는지 여부에 관계 없이 동일한 모양이 있는 합니다.

MenuItemStyleCollection 클래스는 대부분의 멤버에서 상속 된 StateManagedCollection 클래스입니다. 상속된 된 멤버에 대 한 자세한 내용은 참조 하세요. StateManagedCollection합니다.

속성

Count

StateManagedCollection 컬렉션에 포함된 요소의 개수를 가져옵니다.

(다음에서 상속됨 StateManagedCollection)
Item[Int32]

컬렉션에서 지정된 인덱스에 있는 MenuItemStyle 개체를 가져옵니다.

메서드

Add(MenuItemStyle)

지정된 MenuItemStyle 개체를 현재 컬렉션의 끝에 추가합니다.

Clear()

StateManagedCollection 컬렉션에서 모든 항목을 제거합니다.

(다음에서 상속됨 StateManagedCollection)
Contains(MenuItemStyle)

지정된 MenuItemStyle 개체가 컬렉션에 있는지 여부를 확인합니다.

CopyTo(Array, Int32)

특정 배열 인덱스부터 StateManagedCollection 컬렉션의 요소를 배열에 복사합니다.

(다음에서 상속됨 StateManagedCollection)
CopyTo(MenuItemStyle[], Int32)

대상 배열의 지정한 인덱스부터 시작하여 MenuItemStyleCollection 개체의 모든 항목을 MenuItemStyle 개체의 호환되는 1차원 배열에 복사합니다.

CreateKnownType(Int32)

파생 클래스에서 재정의된 경우 IStateManager를 구현하는 클래스의 인스턴스를 만듭니다. 만들어진 개체의 형식은 GetKnownTypes() 메서드에서 반환된 컬렉션의 지정된 멤버를 기반으로 합니다.

(다음에서 상속됨 StateManagedCollection)
Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetEnumerator()

StateManagedCollection 컬렉션을 반복하는 반복기를 반환합니다.

(다음에서 상속됨 StateManagedCollection)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetKnownTypes()

파생 클래스에서 재정의된 경우 StateManagedCollection 컬렉션에 포함할 수 있는 IStateManager 형식의 배열을 가져옵니다.

(다음에서 상속됨 StateManagedCollection)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IndexOf(MenuItemStyle)

컬렉션에서 지정된 MenuItemStyle 개체의 인덱스를 확인합니다.

Insert(Int32, MenuItemStyle)

지정된 MenuItemStyle 개체를 컬렉션의 지정된 인덱스 위치에 삽입합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
OnClear()

파생 클래스에서 재정의된 경우 Clear() 메서드가 컬렉션에서 항목을 모두 제거하기 전에 추가 작업을 수행합니다.

(다음에서 상속됨 StateManagedCollection)
OnClearComplete()

파생 클래스에서 재정의된 경우 Clear() 메서드가 컬렉션에서 항목을 모두 제거한 후 추가 작업을 수행합니다.

(다음에서 상속됨 StateManagedCollection)
OnInsert(Int32, Object)

파생 클래스에서 재정의된 경우 IList.Insert(Int32, Object) 또는 IList.Add(Object) 메서드가 컬렉션에 항목을 추가하기 전에 추가 작업을 수행합니다.

(다음에서 상속됨 StateManagedCollection)
OnInsertComplete(Int32, Object)

파생 클래스에서 재정의된 경우 IList.Insert(Int32, Object) 또는 IList.Add(Object) 메서드가 컬렉션에 항목을 추가한 후 추가 작업을 수행합니다.

(다음에서 상속됨 StateManagedCollection)
OnRemove(Int32, Object)

파생 클래스에서 재정의된 경우 IList.Remove(Object) 또는 IList.RemoveAt(Int32) 메서드가 컬렉션에서 지정한 항목을 제거하기 전에 추가 작업을 수행합니다.

(다음에서 상속됨 StateManagedCollection)
OnRemoveComplete(Int32, Object)

파생 클래스에서 재정의된 경우 IList.Remove(Object) 또는 IList.RemoveAt(Int32) 메서드가 컬렉션에서 지정한 항목을 제거한 후에 추가 작업을 수행합니다.

(다음에서 상속됨 StateManagedCollection)
OnValidate(Object)

파생 클래스에서 재정의된 경우 StateManagedCollection 컬렉션 요소의 유효성을 검사합니다.

(다음에서 상속됨 StateManagedCollection)
Remove(MenuItemStyle)

컬렉션에서 지정된 MenuItemStyle 개체를 제거합니다.

RemoveAt(Int32)

컬렉션의 지정된 인덱스 위치에서 MenuItemStyle 개체를 제거합니다.

SetDirty()

전체 StateManagedCollection 컬렉션이 뷰 상태에 직렬화되도록 합니다.

(다음에서 상속됨 StateManagedCollection)
SetDirtyObject(Object)

파생 클래스에서 재정의된 경우 변경 정보만 기록하는 대신 전체 상태를 뷰 상태에 기록하도록 컬렉션에 포함된 object에 지시합니다.

(다음에서 상속됨 StateManagedCollection)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

ICollection.Count

StateManagedCollection 컬렉션에 포함된 요소의 개수를 가져옵니다.

(다음에서 상속됨 StateManagedCollection)
ICollection.IsSynchronized

StateManagedCollection 컬렉션이 동기화되어 스레드로부터 안전하게 보호되는지 여부를 나타내는 값을 가져옵니다. 이 메서드는 항상 false를 반환합니다.

(다음에서 상속됨 StateManagedCollection)
ICollection.SyncRoot

StateManagedCollection 컬렉션에 대한 액세스를 동기화하는 데 사용할 수 있는 개체를 가져옵니다. 이 메서드는 항상 null를 반환합니다.

(다음에서 상속됨 StateManagedCollection)
IEnumerable.GetEnumerator()

StateManagedCollection 컬렉션을 반복하는 반복기를 반환합니다.

(다음에서 상속됨 StateManagedCollection)
IList.Add(Object)

StateManagedCollection 컬렉션에 항목을 추가합니다.

(다음에서 상속됨 StateManagedCollection)
IList.Clear()

StateManagedCollection 컬렉션에서 모든 항목을 제거합니다.

(다음에서 상속됨 StateManagedCollection)
IList.Contains(Object)

StateManagedCollection 컬렉션에 특정 값이 있는지 여부를 확인합니다.

(다음에서 상속됨 StateManagedCollection)
IList.IndexOf(Object)

StateManagedCollection 컬렉션에서 지정한 항목의 인덱스를 확인합니다.

(다음에서 상속됨 StateManagedCollection)
IList.Insert(Int32, Object)

항목을 StateManagedCollection 컬렉션 내의 지정한 인덱스에 삽입합니다.

(다음에서 상속됨 StateManagedCollection)
IList.IsFixedSize

StateManagedCollection 컬렉션의 크기가 고정되어 있는지 여부를 나타내는 값을 가져옵니다. 이 메서드는 항상 false를 반환합니다.

(다음에서 상속됨 StateManagedCollection)
IList.IsReadOnly

StateManagedCollection 컬렉션이 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 StateManagedCollection)
IList.Item[Int32]

지정된 인덱스에 있는 IStateManager 요소를 가져옵니다.

(다음에서 상속됨 StateManagedCollection)
IList.Remove(Object)

StateManagedCollection 컬렉션에서 맨 처음 발견되는 지정된 개체를 제거합니다.

(다음에서 상속됨 StateManagedCollection)
IList.RemoveAt(Int32)

지정한 인덱스에 있는 IStateManager 요소를 제거합니다.

(다음에서 상속됨 StateManagedCollection)
IStateManager.IsTrackingViewState

StateManagedCollection 컬렉션에서 해당 뷰 상태의 변경 내용을 저장하는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 StateManagedCollection)
IStateManager.LoadViewState(Object)

이전에 저장된 StateManagedCollection 컬렉션과 이 컬렉션에 포함된 IStateManager 항목의 뷰 상태를 복원합니다.

(다음에서 상속됨 StateManagedCollection)
IStateManager.SaveViewState()

페이지가 서버에 포스트백된 이후에 발생한 StateManagedCollection 컬렉션과 이 컬렉션에 포함된 각 IStateManager 개체의 변경 내용을 저장합니다.

(다음에서 상속됨 StateManagedCollection)
IStateManager.TrackViewState()

StateManagedCollection 컬렉션과 이 컬렉션에 포함된 각 IStateManager 개체가 해당 뷰 상태의 변경 내용을 추적하여 같은 페이지에서 발생하는 여러 요청에 대해 유지할 수 있도록 합니다.

(다음에서 상속됨 StateManagedCollection)

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보