Menu 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
주의
Menu is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use ToolStripDropDown and ToolStripDropDownMenu instead.
모든 메뉴의 기본 기능을 나타냅니다.
이 클래스는 .NET Core 3.1 이상 버전에서는 사용할 수 없습니다. ToolStripDropDown ToolStripDropDownMenu 대신 컨트롤을 바꾸고 확장합니다Menu.
public ref class Menu abstract : System::ComponentModel::Component
[System.ComponentModel.ListBindable(false)]
public abstract class Menu : System.ComponentModel.Component
[System.ComponentModel.ListBindable(false)]
[System.ComponentModel.Browsable(false)]
[System.Obsolete("`Menu` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `ToolStripDropDown` and `ToolStripDropDownMenu` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
public abstract class Menu : System.ComponentModel.Component
[<System.ComponentModel.ListBindable(false)>]
type Menu = class
inherit Component
[<System.ComponentModel.ListBindable(false)>]
[<System.ComponentModel.Browsable(false)>]
[<System.Obsolete("`Menu` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `ToolStripDropDown` and `ToolStripDropDownMenu` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
type Menu = class
inherit Component
Public MustInherit Class Menu
Inherits Component
- 상속
- 파생
- 특성
예제
다음 코드 예제에서는 파생된 클래스 MenuItem를 사용 하 여 폼에 대 한 메뉴 구조를 만듭니다. 예제 코드는 최상위 메뉴 항목을 나타내는 mainMenu1menuItem1된 MainMenu 네 개의 MenuItem 개체 , menuItem2및 menuItem3menuItem4.
public:
void CreateMyMenu()
{
// Set the caption for the top-level menu item.
menuItem1->Text = "Edit";
// Set the caption for the first submenu.
menuItem2->Text = "Font Size";
// Set the caption for menuItem2's first submenu.
menuItem3->Text = "Small";
// Set the checked property to true since this is the default value.
menuItem3->Checked = true;
// Define a shortcut key combination for the menu item.
menuItem3->Shortcut = Shortcut::CtrlS;
// Set the caption of the second sub menu item of menuItem2.
menuItem4->Text = "Large";
// Define a shortcut key combination for the menu item.
menuItem4->Shortcut = Shortcut::CtrlL;
// Set the index of the menu item so it is placed below the first submenu item.
menuItem4->Index = 1;
// Add menuItem3 and menuItem4 to menuItem2's list of menu items.
menuItem2->MenuItems->Add( menuItem3 );
menuItem2->MenuItems->Add( menuItem4 );
// Add menuItem2 to menuItem1's list of menu items.
menuItem1->MenuItems->Add( menuItem2 );
// Add menuItem1 to the MainMenu for displaying.
mainMenu1->MenuItems->Add( menuItem1 );
}
public void CreateMyMenu()
{
// Set the caption for the top-level menu item.
menuItem1.Text = "Edit";
// Set the caption for the first submenu.
menuItem2.Text = "Font Size";
// Set the caption for menuItem2's first submenu.
menuItem3.Text = "Small";
// Set the checked property to true since this is the default value.
menuItem3.Checked = true;
// Define a shortcut key combination for the menu item.
menuItem3.Shortcut = Shortcut.CtrlS;
// Set the caption of the second sub menu item of menuItem2.
menuItem4.Text = "Large";
// Define a shortcut key combination for the menu item.
menuItem4.Shortcut = Shortcut.CtrlL;
// Set the index of the menu item so it is placed below the first submenu item.
menuItem4.Index = 1;
// Add menuItem3 and menuItem4 to menuItem2's list of menu items.
menuItem2.MenuItems.Add(menuItem3);
menuItem2.MenuItems.Add(menuItem4);
// Add menuItem2 to menuItem1's list of menu items.
menuItem1.MenuItems.Add(menuItem2);
// Add menuItem1 to the MainMenu for displaying.
mainMenu1.MenuItems.Add(menuItem1);
}
Public Sub CreateMyMenu()
' Set the caption for the top-level menu item.
menuItem1.Text = "Edit"
' Set the caption for the first submenu.
menuItem2.Text = "Font Size"
' Set the caption for menuItem2's first submenu.
menuItem3.Text = "Small"
' Set the checked property to true since this is the default value.
menuItem3.Checked = True
' Define a shortcut key combination for the menu item.
menuItem3.Shortcut = Shortcut.CtrlS
' Set the caption of the second sub menu item of menuItem2.
menuItem4.Text = "Large"
' Define a shortcut key combination for the menu item.
menuItem4.Shortcut = Shortcut.CtrlL
' Set the index of the menu item so it is placed below the first submenu item.
menuItem4.Index = 1
' Add menuItem3 and menuItem4 to menuItem2's list of menu items.
menuItem2.MenuItems.Add(menuItem3)
menuItem2.MenuItems.Add(menuItem4)
' Add menuItem2 to menuItem1's list of menu items.
menuItem1.MenuItems.Add(menuItem2)
' Add menuItem1 to the MainMenu for displaying.
mainMenu1.MenuItems.Add(menuItem1)
End Sub
설명
이 클래스는 .NET Core 3.1 이상 버전에서는 사용할 수 없습니다. 대신 ToolStripDropDown 및 ToolStripDropDownMenu을 사용하세요.
이 클래스는 , MainMenu및 MenuItem 클래스의 ContextMenu기본 클래스입니다. 이 클래스의 인스턴스를 만들 수 없습니다. 애플리케이션의 메뉴는 개체로 MenuItem 구성됩니다. 하위 메뉴 항목을 나타내는 다른 MenuItem 개체를 포함할 수 있습니다. 개체 MainMenu 는 MenuItem 폼의 전체 메뉴 구조 또는 ContextMenu 바로 가기 메뉴를 표시하는 데 사용되는 전체 메뉴 구조로 표시할 수 있습니다. 이 클래스는 모든 메뉴 클래스에 공통적인 기능을 제공합니다.
많은 기본 클래스와 달리 클래스는 Menu 파생 클래스를 사용하여 많은 속성을 정의합니다. MDI(다중 문서 인터페이스) 애플리케이션에서 메뉴를 사용하는 경우 이 속성을 사용하여 MdiListItem 애플리케이션에서 열린 MDI 자식 양식 목록을 표시하는 속성을 지정할 MenuItem 수 있습니다. 이 속성은 MenuItems 메뉴 클래스에 저장된 개체 목록을 MenuItem 포함합니다. 또는 MainMenuContextMenu이 속성에 표시되는 모든 개체가 MenuItem 포함됩니다. 의 MenuItem경우 속성은 MenuItems 연결된 하위 메뉴 항목을 나타냅니다.
모든 파생 메뉴 클래스에 대해 제공되는 속성 외에도 클래스 Menu 는 기존 메뉴에서 새 메뉴를 만들고 두 메뉴 구조를 함께 병합할 수 있는 메서드(예MergeMenuCloneMenu: 및)를 제공합니다.
클래스는 Menu 중첩된 클래스 Menu.MenuItemCollection도 정의합니다. 이 클래스는 속성에서 사용하는 MenuItems 개체의 MenuItem 컬렉션을 정의합니다. 클래스의 Menu.MenuItemCollection 메서드를 사용하여 메뉴 항목을 MainMenuContextMenuMenuItem추가 및 제거할 수 있습니다.
생성자
| Name | Description |
|---|---|
| Menu(MenuItem[]) |
사용되지 않음.
Menu 클래스의 새 인스턴스를 초기화합니다. |
필드
| Name | Description |
|---|---|
| FindHandle |
사용되지 않음.
메서드가 핸들을 FindMenuItem(Int32, IntPtr) 검색할 수 있도록 지정합니다. |
| FindShortcut |
사용되지 않음.
메서드가 바로 가기를 FindMenuItem(Int32, IntPtr) 검색할 수 있도록 지정합니다. |
속성
| Name | Description |
|---|---|
| CanRaiseEvents |
사용되지 않음.
구성 요소가 이벤트를 발생시키는지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 Component) |
| Container |
사용되지 않음.
를 IContainer 포함하는 값을 가져옵니다 Component. (다음에서 상속됨 Component) |
| DesignMode |
사용되지 않음.
현재 디자인 모드인지 여부를 Component 나타내는 값을 가져옵니다. (다음에서 상속됨 Component) |
| Events |
사용되지 않음.
이 Component에 연결된 이벤트 처리기 목록을 가져옵니다. (다음에서 상속됨 Component) |
| Handle |
사용되지 않음.
메뉴의 창 핸들을 나타내는 값을 가져옵니다. |
| IsParent |
사용되지 않음.
이 메뉴에 메뉴 항목이 포함되어 있는지 여부를 나타내는 값을 가져옵니다. 이 속성은 읽기 전용입니다. |
| MdiListItem |
사용되지 않음.
MDI(여러 문서 인터페이스) 자식 양식의 목록을 표시하는 데 사용되는 값을 가져옵니다 MenuItem . |
| MenuItems |
사용되지 않음.
메뉴와 연결된 개체의 MenuItem 컬렉션을 나타내는 값을 가져옵니다. |
| Name |
사용되지 않음.
의 이름을 Menu가져오거나 설정합니다. |
| Site |
사용되지 않음.
의 ISite값을 Component 가져오거나 설정합니다. (다음에서 상속됨 Component) |
| Tag |
사용되지 않음.
컨트롤과 연결된 사용자 정의 데이터를 가져오거나 설정합니다. |
메서드
| Name | Description |
|---|---|
| CloneMenu(Menu) |
사용되지 않음.
|
| CreateMenuHandle() |
사용되지 않음.
에 대한 새 핸들을 Menu만듭니다. |
| CreateObjRef(Type) |
사용되지 않음.
원격 개체와 통신하는 데 사용되는 프록시를 생성하는 데 필요한 모든 관련 정보를 포함하는 개체를 만듭니다. (다음에서 상속됨 MarshalByRefObject) |
| Dispose() |
사용되지 않음.
에서 사용하는 모든 리소스를 Component해제합니다. (다음에서 상속됨 Component) |
| Dispose(Boolean) |
사용되지 않음.
에서 사용하는 메모리 이외의 리소스를 Menu삭제합니다. |
| Equals(Object) |
사용되지 않음.
지정된 개체가 현재 개체와 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| FindMenuItem(Int32, IntPtr) |
사용되지 않음.
MenuItem 지정된 값을 포함하는 값을 가져옵니다. |
| FindMergePosition(Int32) |
사용되지 않음.
메뉴 항목이 메뉴에 삽입되어야 하는 위치를 반환합니다. |
| GetContextMenu() |
사용되지 않음.
이 메뉴가 ContextMenu 포함된 항목을 가져옵니다. |
| GetHashCode() |
사용되지 않음.
기본 해시 함수로 사용됩니다. (다음에서 상속됨 Object) |
| GetLifetimeService() |
사용되지 않음.
이 인스턴스의 수명 정책을 제어하는 현재 수명 서비스 개체를 검색합니다. (다음에서 상속됨 MarshalByRefObject) |
| GetMainMenu() |
사용되지 않음.
이 메뉴가 MainMenu 포함된 항목을 가져옵니다. |
| GetService(Type) |
사용되지 않음.
또는 해당 서비스에서 제공하는 서비스를 나타내는 개체를 Component 반환합니다 Container. (다음에서 상속됨 Component) |
| GetType() |
사용되지 않음.
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| InitializeLifetimeService() |
사용되지 않음.
이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다. (다음에서 상속됨 MarshalByRefObject) |
| MemberwiseClone() |
사용되지 않음.
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| MemberwiseClone(Boolean) |
사용되지 않음.
현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다. (다음에서 상속됨 MarshalByRefObject) |
| MergeMenu(Menu) |
사용되지 않음.
한 메뉴의 MenuItem 개체를 현재 메뉴와 병합합니다. |
| ProcessCmdKey(Message, Keys) |
사용되지 않음.
명령 키를 처리합니다. |
| ToString() |
사용되지 않음.
|
이벤트
| Name | Description |
|---|---|
| Disposed |
사용되지 않음.
구성 요소가 메서드 호출에 Dispose() 의해 삭제될 때 발생합니다. (다음에서 상속됨 Component) |