다음을 통해 공유


MenuItem.Index 속성

부모 메뉴에서의 메뉴 항목 위치를 나타내는 값을 가져오거나 설정합니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Property Index As Integer
‘사용 방법
Dim instance As MenuItem
Dim value As Integer

value = instance.Index

instance.Index = value
public int Index { get; set; }
public:
property int Index {
    int get ();
    void set (int value);
}
/** @property */
public int get_Index ()

/** @property */
public void set_Index (int value)
public function get Index () : int

public function set Index (value : int)

속성 값

부모 메뉴에서의 메뉴 항목 위치를 나타내며 0부터 시작하는 인덱스입니다.

예외

예외 형식 조건

ArgumentOutOfRangeException

할당된 값이 0보다 작거나 항목 수보다 큰 경우

설명

이 속성은 부모 메뉴의 메뉴 항목 컬렉션에서 메뉴 항목의 인덱싱된 위치를 제공합니다. 이 속성을 사용하여 메뉴 내의 다른 위치로 메뉴 항목의 위치를 변경할 수 있습니다. 또한 MenuItem을 만들 때 이 속성을 사용하면 메뉴 구조에서의 위치를 지정할 수도 있습니다.

예제

다음 코드 예제에서는 메뉴에 있는 두 메뉴 항목의 위치를 바꿉니다. 다음 코드 예제를 실행하려면 menuItem1menuItem2라는 두 MenuItem 개체가 만들어져 있어야 합니다. menuItem1 메뉴 항목은 메뉴에서 한 위치 아래로 이동하고, menuItem2 메뉴 항목은 한 위치 위로 이동합니다.

Public Sub SwitchMyMenuItems()
    ' Move menuItem1 down one position in the menu order.
    menuItem1.Index = menuItem1.Index + 1
    ' Move menuItem2 up one position in the menu order.
    menuItem2.Index = menuItem2.Index - 1
End Sub
public void SwitchMyMenuItems()
{
   // Move menuItem1 down one position in the menu order.
   menuItem1.Index = menuItem1.Index + 1;
   // Move menuItem2 up one position in the menu order.
   menuItem2.Index = menuItem2.Index - 1;
}
public:
   void SwitchMyMenuItems()
   {
      // Move menuItem1 down one position in the menu order.
      menuItem1->Index = menuItem1->Index + 1;
      // Move menuItem2 up one position in the menu order.
      menuItem2->Index = menuItem2->Index - 1;
   }
public void SwitchMyMenuItems()
{
    // Move menuItem1 down one position in the menu order.
    menuItem1.set_Index(menuItem1.get_Index() + 1);
    // Move menuItem2 up one position in the menu order.
    menuItem2.set_Index(menuItem2.get_Index() - 1);
} //SwitchMyMenuItems

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

MenuItem 클래스
MenuItem 멤버
System.Windows.Forms 네임스페이스