MenuItem イベント

名前 | 説明 | |
---|---|---|
![]() | Click | メニュー項目に対して定義されているショートカット キーまたはアクセス キーを使用して、そのメニュー項目がクリックまたは選択されると発生します。 |
![]() | Disposed | コンポーネントの Disposed イベントを待機するイベント ハンドラを追加します。 ( Component から継承されます。) |
![]() | Select | ユーザーがメニュー項目の上にポインタを置いた場合に発生します。 |

MenuItem クラス
アセンブリ: System.Web (system.web.dll 内)


Menu コントロールは、MenuItem オブジェクトによって表されるメニュー項目の階層で構成されます。各メニュー項目には、Menu コントロール内でのそのメニュー項目の表示レベルを指定する、読み取り専用の Depth プロパティがあります。親メニュー項目を持たない最上位 (レベル 0) のメニュー項目をルート メニュー項目と呼びます。親メニュー項目を持つメニュー項目をサブメニュー項目と呼びます。すべてのルート メニュー項目は Items コレクションに格納されます。サブメニュー項目は、親メニュー項目の ChildItems コレクションに格納されます。メニュー項目の親メニュー項目には、Parent プロパティを使用してアクセスできます。
![]() |
---|
Items コレクションと ChildItems コレクションには、1 つ下のレベルのメニュー項目だけが含まれます。メニュー ツリーのさらに下のメニュー項目にアクセスするには、後続のメニュー項目の ChildItems プロパティを使用します。 |
Menu コントロールのメニュー項目を作成するには、次のいずれかのメソッドを使用します。
コンストラクタを使用して、MenuItem クラスの新しいインスタンスを動的に作成します。後で、これらの MenuItem オブジェクトを Items コレクションまたは ChildItems コレクションに追加できます。
Menu コントロールをデータ ソースにバインドします。Menu コントロールが SiteMapDataSource コントロールにバインドされると、データ ソース内の項目に対応する MenuItem オブジェクトが自動的に作成されます。他のデータ ソースについても、データ ソースの階層構造に一致する MenuItem オブジェクトが自動的に作成されます。ただし DataBindings コレクションを使用してメニュー項目のバインディングを定義し、メニュー項目とそれに対応するデータ項目の間のバインディング関係を指定することも必要です。
メニュー項目はそのレベルに従って、静的メニューまたは動的メニューのどちらかに表示されます。静的メニューは常に Menu コントロールに表示されます。既定では、最上位 (レベル 0) のメニュー項目は静的メニューに表示されます。StaticDisplayLevels プロパティを設定して、静的メニューにメニュー レベル (静的サブメニュー) を追加表示できます。StaticDisplayLevels プロパティで指定されている値よりも高いレベルのメニュー項目がある場合、それは動的なサブメニューに表示されます。動的なサブメニューは、動的なサブメニューを持つ親メニュー項目の上にユーザーがマウス ポインタを置いた場合にのみ表示されます。
ユーザーがメニュー項目をクリックすると、Menu コントロールはリンクされた Web ページにナビゲートするか、単純にサーバーにポストバックします。メニュー項目の NavigateUrl プロパティが設定されている場合、Menu コントロールはリンクされたページにナビゲートします。それ以外の場合は、処理を行うためにページをサーバーにポストバックします。既定では、リンクされたページは Menu コントロールと同じウィンドウまたは枠に表示されます。リンクされたコンテンツを別のウィンドウまたは枠に表示するには、Menu コントロールの Target プロパティを使用します。
![]() |
---|
Menu.Target プロパティは、コントロールのすべてのメニュー項目に影響します。メニュー項目ごとにウィンドウまたは枠を指定するには、MenuItem オブジェクトの Target プロパティを直接設定します。 |
メニュー項目ごとに Text と Value プロパティがあります。メニュー項目に関連付けられているポストバック イベントに渡されるデータなど、メニュー項目に関する補足データを格納するために Value プロパティが使用されている間、Text プロパティの値は Menu コントロールに表示されます。Text プロパティを設定し、Value プロパティを設定しないと、Value プロパティには Text プロパティと同じ値が自動的に設定されます。その反対も同様です。Value プロパティを設定し、Text プロパティを設定しないと、Text プロパティには Value プロパティと同じ値が自動的に設定されます。
![]() |
---|
同じメニュー レベルにあるメニュー項目は、それぞれの Value プロパティの値が一意であることが必要です。同一レベルの複数のメニュー項目でこの値が同じであると、Menu コントロールは各メニュー項目を区別できません。この場合、重複した値を持つメニュー項目をユーザーがクリックすると、最初にメニューに表示されているメニュー項目が選択されます。 |
ユーザーがマウス ポインタをメニュー項目の上に置いたときにツールヒントを表示するには、その項目の ToolTip プロパティを設定します。
Menu コントロールには、さまざまな種類のメニュー項目があります。次の表に示すプロパティを使用して、メニュー項目の種類ごとにフォント サイズや色などのスタイルを制御できます。
DynamicHoverStyle | |
DynamicMenuItemStyle | |
DynamicMenuStyle | |
DynamicSelectedStyle | |
StaticHoverStyle | |
StaticMenuItemStyle | |
StaticMenuStyle | |
StaticSelectedStyle |
スタイルのプロパティを個々に設定する代わりに、次の表に示すスタイル コレクションを使用して、レベルに基づいてメニュー項目に適用するスタイルを指定できます。
LevelMenuItemStyles | |
LevelSelectedStyles | |
LevelSubMenuStyles |
このコレクションの中の最初のスタイルは、メニュー ツリーの 1 番目の深さレベルにあるメニュー項目のスタイルに対応します。このコレクションの中の 2 番目のスタイルは、メニュー ツリーの 2 番目の深さレベルにあるメニュー項目のスタイルに対応し、以下同様に対応します。サブメニューの有無にかかわらず、一定の深さレベルにあるメニュー項目の外観を同じにする場合は、この方法でコンテンツ-スタイルのナビゲーション メニューのテーブルを生成するのが最も一般的です。
![]() |
---|
前述のテーブルにリストされているスタイル レベルのコレクションを使用して Menu コントロールのスタイルを定義すると、それらのスタイル設定が、個々のメニュー項目のスタイルのプロパティをオーバーライドします。 |
メニュー項目のスタイルだけでなく、その外観もカスタマイズできます。次の表に示すプロパティを設定して、メニュー項目の部分ごとにカスタム イメージを指定できます。
ImageUrl | |
PopOutImageUrl | |
SeparatorImageUrl |
Menu コントロールでメニュー項目が現在選択されているかどうかを確認するには、Selected プロパティを使用します。DataBound プロパティを使用して、メニュー項目がデータにバインドされているかどうかを確認することもできます。メニュー項目がデータにバインドされている場合は、DataItem プロパティを使用して、メニュー項目にバインドされたデータ項目の値にアクセスできます。
MenuItem クラスのインスタンスの初期プロパティ値の一覧については、MenuItem コンストラクタのトピックを参照してください。

宣言構文を使用して、静的な MenuItem オブジェクトの Menu コントロールを作成する方法のコード例を次に示します。
<%@ Page Language="VB" %> <html> <body> <form runat="server"> <h3>MenuItem Declarative Example</h3> <!-- Use declarative syntax to create the --> <!-- menu structure. Create submenu items --> <!-- by nesting them within parent menu --> <!-- items. --> <asp:menu id="NavigationMenu" staticdisplaylevels="1" staticsubmenuindent="10" orientation="Vertical" target="_blank" runat="server"> <items> <asp:menuitem navigateurl="Home.aspx" text="Home" imageurl="Images\Home.gif" popoutimageurl="Images\Popout.jpg" tooltip="Home"> <asp:menuitem navigateurl="Music.aspx" text="Music" popoutimageurl="Images\Popout.jpg" tooltip="Music"> <asp:menuitem navigateurl="Classical.aspx" text="Classical" separatorimageurl="Images\Separator.jpg" tooltip="Classical"/> <asp:menuitem navigateurl="Rock.aspx" text="Rock" separatorimageurl="Images\Separator.jpg" tooltip="Rock"/> <asp:menuitem navigateurl="Jazz.aspx" text="Jazz" separatorimageurl="Images\Separator.jpg" tooltip="Jazz"/> </asp:menuitem> <asp:menuitem navigateurl="Movies.aspx" text="Movies" popoutimageurl="Images\Popout.jpg" tooltip="Movies"> <asp:menuitem navigateurl="Action.aspx" text="Action" separatorimageurl="Images\Separator.jpg" tooltip="Action"/> <asp:menuitem navigateurl="Drama.aspx" text="Drama" separatorimageurl="Images\Separator.jpg" tooltip="Drama"/> <asp:menuitem navigateurl="Musical.aspx" text="Musical" separatorimageurl="Images\Separator.jpg" tooltip="Musical"/> </asp:menuitem> </asp:menuitem> </items> </asp:menu> </form> </body> </html>
<%@ Page Language="C#" %> <html> <body> <form runat="server"> <h3>MenuItem Declarative Example</h3> <!-- Use declarative syntax to create the --> <!-- menu structure. Create submenu items --> <!-- by nesting them within parent menu --> <!-- items. --> <asp:menu id="NavigationMenu" staticdisplaylevels="1" staticsubmenuindent="10" orientation="Vertical" target="_blank" runat="server"> <items> <asp:menuitem navigateurl="Home.aspx" text="Home" imageurl="Images\Home.gif" popoutimageurl="Images\Popout.jpg" tooltip="Home"> <asp:menuitem navigateurl="Music.aspx" text="Music" popoutimageurl="Images\Popout.jpg" tooltip="Music"> <asp:menuitem navigateurl="Classical.aspx" text="Classical" separatorimageurl="Images\Separator.jpg" tooltip="Classical"/> <asp:menuitem navigateurl="Rock.aspx" text="Rock" separatorimageurl="Images\Separator.jpg" tooltip="Rock"/> <asp:menuitem navigateurl="Jazz.aspx" text="Jazz" separatorimageurl="Images\Separator.jpg" tooltip="Jazz"/> </asp:menuitem> <asp:menuitem navigateurl="Movies.aspx" text="Movies" popoutimageurl="Images\Popout.jpg" tooltip="Movies"> <asp:menuitem navigateurl="Action.aspx" text="Action" separatorimageurl="Images\Separator.jpg" tooltip="Action"/> <asp:menuitem navigateurl="Drama.aspx" text="Drama" separatorimageurl="Images\Separator.jpg" tooltip="Drama"/> <asp:menuitem navigateurl="Musical.aspx" text="Musical" separatorimageurl="Images\Separator.jpg" tooltip="Musical"/> </asp:menuitem> </asp:menuitem> </items> </asp:menu> </form> </body> </html>
Menu コントロールを SiteMapDataSource コントロールにバインドする方法のコード例を次に示します。Menu コントロールはデータ ソースにバインドされると、MenuItem オブジェクトを自動的に作成します。この例を正常に動作させるには、以下のサンプル サイト マップ データを、Web.sitemap という名前のファイルにコピーする必要があります。
<%@ Page Language="VB" %> <html> <!-- For the hover styles of the Menu control to --> <!-- work correctly, you must include this head --> <!-- element. --> <head runat="server"> </head> <body> <form runat="server"> <h3>Menu DataBinding Example</h3> <!-- Bind the Menu control to a SiteMapDataSource control. --> <asp:menu id="NavigationMenu" disappearafter="2000" staticdisplaylevels="2" staticsubmenuindent="10" orientation="Vertical" font-names="Arial" target="_blank" datasourceid="MenuSource" runat="server"> <staticmenuitemstyle backcolor="LightSteelBlue" forecolor="Black"/> <statichoverstyle backcolor="LightSkyBlue"/> <dynamicmenuitemstyle backcolor="Black" forecolor="Silver"/> <dynamichoverstyle backcolor="LightSkyBlue" forecolor="Black"/> </asp:menu> <asp:SiteMapDataSource id="MenuSource" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" %> <html> <!-- For the hover styles of the Menu control to --> <!-- work correctly, you must include this head --> <!-- element. --> <head runat="server"> </head> <body> <form runat="server"> <h3>Menu DataBinding Example</h3> <!-- Bind the Menu control to a SiteMapDataSource control. --> <asp:menu id="NavigationMenu" disappearafter="2000" staticdisplaylevels="2" staticsubmenuindent="10" orientation="Vertical" font-names="Arial" target="_blank" datasourceid="MenuSource" runat="server"> <staticmenuitemstyle backcolor="LightSteelBlue" forecolor="Black"/> <statichoverstyle backcolor="LightSkyBlue"/> <dynamicmenuitemstyle backcolor="Black" forecolor="Silver"/> <dynamichoverstyle backcolor="LightSkyBlue" forecolor="Black"/> </asp:menu> <asp:SiteMapDataSource id="MenuSource" runat="server"/> </form> </body> </html>
<siteMap>
<siteMapNode url="~\Home.aspx"
description="Home">
<siteMapNode url="~\Music.aspx"
description="Music">
<siteMapNode url="~\Classical.aspx"
description="Classical"/>
<siteMapNode url="~\Rock.aspx"
description="Rock"/>
<siteMapNode url="~\Jazz.aspx"
description="Jazz"/>
</siteMapNode>
<siteMapNode url="~\Movies.aspx"
<siteMapNode url="~\Action.aspx"
description="Action"/>
<siteMapNode url="~\Drama.aspx"
description="Drama"/>
<siteMapNode url="~\Musical.aspx"
description="Musical"/>
</siteMapNode>
</siteMapNode>
</siteMap>


System.Web.UI.WebControls.MenuItem


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItem クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


MenuItem を表示するには、MainMenu または ContextMenu に追加する必要があります。サブメニューを作成するには、MenuItem オブジェクトを親 MenuItem の MenuItems プロパティに追加します。
MenuItem クラスには、メニュー項目の外観と機能を設定するためのプロパティがあります。メニュー項目の横にチェック マークを表示するには、Checked プロパティを使用します。この機能を使用すると、一度に 1 つしか選択できない複数のメニュー項目の中で、選択されている 1 つのメニュー項目を識別できます。たとえば、TextBox コントロールのテキストの色を設定するメニュー項目が複数ある場合、Checked プロパティを使用して、現在選択されている色を識別できます。Shortcut プロパティを使用すると、組み合わせて押すことによってメニュー項目を選択できるショートカット キーを定義できます。
マルチ ドキュメント インターフェイス (MDI: Multiple Document Interface) アプリケーションに表示される MenuItem オブジェクトの場合、MergeMenu メソッドを使用して、MDI 親のメニューと、その子フォームのメニューをマージし、統合したメニュー構造を作成できます。MenuItem は、複数の場所 (MainMenu と ContextMenu など) で同時には使用できないため、別の場所で使用する場合は、CloneMenu メソッドを使用して MenuItem のコピーを作成できます。
Popup イベントを使用すると、メニューを表示する前にタスクを実行できるようになります。たとえば、このイベントを処理するイベント ハンドラを作成し、コードの状態に基づいてメニュー項目を表示したり非表示にしたりできます。Select イベントを使用すると、ユーザーがアプリケーションのメニュー項目上にマウス ポインタを置いたときに、その項目に関する詳しいヘルプを表示するなどのタスクを実行できます。

フォームで使用するメニュー構造を作成するコード例を次に示します。この例では、トップレベル メニューの項目を表す MenuItem を追加して、フォント サイズを選択するためのサブメニュー項目を追加します。さらに、そのサブメニュー項目にアプリケーションの大小のフォントの選択肢を表す 2 つのサブメニュー項目を追加します。この例では、mainMenu1 という名前の MainMenu オブジェクト、および menuItem1、menuItem2、menuItem3、menuItem4 という名前の 4 つの MenuItem オブジェクトが作成されている必要があります。
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
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 void CreateMyMenu() { // Set the caption for the top-level menu item. menuItem1.set_Text("Edit"); // Set the caption for the first submenu. menuItem2.set_Text("Font Size"); // Set the caption for menuItem2's first submenu. menuItem3.set_Text("Small"); // Set the checked property to true since this is the default value. menuItem3.set_Checked(true); // Define a shortcut key combination for the menu item. menuItem3.set_Shortcut(Shortcut.CtrlS); // Set the caption of the second sub menu item of menuItem2. menuItem4.set_Text("Large"); // Define a shortcut key combination for the menu item. menuItem4.set_Shortcut(Shortcut.CtrlL); // Set the index of the menu item so it is placed below //the first submenu item. menuItem4.set_Index(1); // Add menuItem3 and menuItem4 to menuItem2's list of menu items. menuItem2.get_MenuItems().Add(menuItem3); menuItem2.get_MenuItems().Add(menuItem4); // Add menuItem2 to menuItem1's list of menu items. menuItem1.get_MenuItems().Add(menuItem2); // Add menuItem1 to the MainMenu for displaying. mainMenu1.get_MenuItems().Add(menuItem1); } //CreateMyMenu

System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Menu
System.Windows.Forms.MenuItem


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItem コンストラクタ ()
アセンブリ: System.Web (system.web.dll 内)


このコンストラクタを使用して、メニュー テキストまたは値を指定せずに MenuItem クラスの新しいインスタンスを作成します。
![]() |
---|
このコンストラクタを使用すると、MenuItem オブジェクトのすべてのプロパティが既定値に設定されます。オブジェクトの作成後に必要に応じてプロパティを設定してください。 |
このコンストラクタは、Menu コントロールの Items コレクションまたは MenuItem オブジェクトの ChildItems コレクションを動的に設定する場合によく使用されます。

このコンストラクタを使用して、MenuItem クラスの新しいインスタンスを作成する方法のコード例を次に示します。その後、MenuItem オブジェクトを使用して、Menu コントロールのメニュー項目が動的に設定されます。
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not IsPostBack Then ' Create the menu structure. ' Create the root menu item. Dim homeMenuItem As MenuItem homeMenuItem = CreateMenuItem("Home", "Home.aspx", "Home") ' Create the submenu items. Dim musicSubMenuItem As MenuItem musicSubMenuItem = CreateMenuItem("Music", "Music.aspx", "Music") Dim moviesSubMenuItem As MenuItem moviesSubMenuItem = CreateMenuItem("Movies", "Movies.aspx", "Movies") ' Add the submenu items to the ChildItems ' collection of the root menu item. homeMenuItem.ChildItems.Add(musicSubMenuItem) homeMenuItem.ChildItems.Add(moviesSubMenuItem) ' Add the root menu item to the Items collection ' of the Menu control. NavigationMenu.Items.Add(homeMenuItem) End If End Sub Function CreateMenuItem(ByVal text As String, ByVal url As String, ByVal toolTip As String) As MenuItem ' Create a new MenuItem object. Dim menuItem As New MenuItem() ' Set the properties of the MenuItem object using ' the specified parameters. MenuItem.Text = text MenuItem.NavigateUrl = url MenuItem.ToolTip = toolTip Return MenuItem End Function </script> <html> <body> <form runat="server"> <h3>MenuItem Constructor Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void Page_Load(Object sender, EventArgs e) { if (!IsPostBack) { // Create the menu structure. // Create the root menu item. MenuItem homeMenuItem; homeMenuItem = CreateMenuItem("Home", "Home.aspx", "Home"); // Create the submenu items. MenuItem musicSubMenuItem; musicSubMenuItem = CreateMenuItem("Music", "Music.aspx", "Music"); MenuItem moviesSubMenuItem; moviesSubMenuItem = CreateMenuItem("Movies", "Movies.aspx", "Movies"); // Add the submenu items to the ChildItems // collection of the root menu item. homeMenuItem.ChildItems.Add(musicSubMenuItem); homeMenuItem.ChildItems.Add(moviesSubMenuItem); // Add the root menu item to the Items collection // of the Menu control. NavigationMenu.Items.Add(homeMenuItem); } } MenuItem CreateMenuItem(String text, String url, String toolTip) { // Create a new MenuItem object. MenuItem menuItem = new MenuItem(); // Set the properties of the MenuItem object using // the specified parameters. menuItem.Text = text; menuItem.NavigateUrl = url; menuItem.ToolTip = toolTip; return menuItem; } </script> <html> <body> <form runat="server"> <h3>MenuItem Constructor Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"/> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItem コンストラクタ ()
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)



このバージョンのコンストラクタを使用して MenuItem を作成するコード例を次に示します。
Public Sub CreateMyMenu() ' Create an empty menu item object. Dim menuItem1 As New MenuItem() ' Intialize the menu item using the parameterless version of the constructor. ' Set the caption of the menu item. menuItem1.Text = "&File" End Sub
public void CreateMyMenu() { // Create an empty menu item object. MenuItem menuItem1 = new MenuItem(); // Intialize the menu item using the parameterless version of the constructor. // Set the caption of the menu item. menuItem1.Text = "&File"; }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItem コンストラクタ (String, String, String, String)
アセンブリ: System.Web (system.web.dll 内)

Public Sub New ( _ text As String, _ value As String, _ imageUrl As String, _ navigateUrl As String _ )
Dim text As String Dim value As String Dim imageUrl As String Dim navigateUrl As String Dim instance As New MenuItem(text, value, imageUrl, navigateUrl)

このコンストラクタを使用して、text パラメータで指定されたメニュー テキスト、value パラメータで指定された値、imageUrl パラメータで指定されたイメージの URL、および navigateUrl パラメータで指定されたナビゲーション URL で、MenuItem クラスの新しいインスタンスを作成します。
MenuItem クラスのインスタンスの初期プロパティ値を次の表に示します。
このコンストラクタは、Menu コントロールの Items コレクションまたは MenuItem オブジェクトの ChildItems コレクションを動的に設定する場合によく使用されます。

このコンストラクタを使用して、MenuItem クラスの新しいインスタンスを作成する方法のコード例を次に示します。その後、MenuItem オブジェクトを使用して、Menu コントロールのメニュー項目が動的に設定されます。
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not IsPostBack Then ' Create the menu structure. ' Create the root menu item. Dim homeMenuItem As New MenuItem("Home", "Root", _ "Images\Home.jpg", "Home.aspx") ' Create the submenu items. Dim musicSubMenuItem As New MenuItem("Music", "Category 1", _ "Images\Music.jpg", "Music.aspx") Dim moviesSubMenuItem As New MenuItem("Movies", "Category 2", _ "Images\Movies.jpg", "Movies.aspx") ' Add the submenu items to the ChildItems ' collection of the root menu item. homeMenuItem.ChildItems.Add(musicSubMenuItem) homeMenuItem.ChildItems.Add(moviesSubMenuItem) ' Add the root menu item to the Items collection ' of the Menu control. NavigationMenu.Items.Add(homeMenuItem) End If End Sub </script> <html> <body> <form runat="server"> <h3>MenuItem Constructor Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void Page_Load(Object sender, EventArgs e) { if (!IsPostBack) { // Create the menu structure. // Create the root menu item. MenuItem homeMenuItem = new MenuItem("Home", "Root" , @"Images\Home.jpg", "Home.aspx"); // Create the submenu items. MenuItem musicSubMenuItem = new MenuItem("Music", "Category 1", @"Images\Music.jpg", "Music.aspx"); MenuItem moviesSubMenuItem = new MenuItem("Movies", "Category 2", @"Images\Movies.jpg", "Movies.aspx"); // Add the submenu items to the ChildItems // collection of the root menu item. homeMenuItem.ChildItems.Add(musicSubMenuItem); homeMenuItem.ChildItems.Add(moviesSubMenuItem); // Add the root menu item to the Items collection // of the Menu control. NavigationMenu.Items.Add(homeMenuItem); } } </script> <html> <body> <form runat="server"> <h3>MenuItem Constructor Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"/> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItem コンストラクタ

名前 | 説明 |
---|---|
MenuItem () | 空白のキャプションを使用して、MenuItem を初期化します。 .NET Compact Framework によってサポートされています。 |
MenuItem (String) | メニュー項目のキャプションを指定して、MenuItem クラスの新しいインスタンスを初期化します。 |
MenuItem (String, EventHandler) | メニュー項目のキャプション、Click イベントを処理するイベント ハンドラを指定して、クラスの新しいインスタンスを初期化します。 |
MenuItem (String, MenuItem[]) | メニュー項目のキャプション、メニュー項目に対して定義されているサブメニュー項目の配列を指定して、クラスの新しいインスタンスを初期化します。 |
MenuItem (String, EventHandler, Shortcut) | メニュー項目のキャプション、イベント ハンドラ、関連付けられているショートカット キーを指定して、クラスの新しいインスタンスを初期化します。 |
MenuItem (MenuMerge, Int32, Shortcut, String, EventHandler, EventHandler, EventHandler, MenuItem[]) | キャプション、Click、Select、Popup の各イベントに対して定義されているイベント ハンドラ、メニュー項目のショートカット キー、マージの種類、およびマージ順序を指定して、MenuItem クラスの新しいインスタンスを初期化します。 |

MenuItem コンストラクタ (String, String)
アセンブリ: System.Web (system.web.dll 内)


このコンストラクタを使用して、text パラメータで指定されたメニュー テキストおよび value パラメータで指定された値で MenuItem クラスの新しいインスタンスを作成します。
MenuItem クラスのインスタンスの初期プロパティ値を次の表に示します。
このコンストラクタは、Menu コントロールの Items コレクションまたは MenuItem オブジェクトの ChildItems コレクションを動的に設定する場合によく使用されます。

このコンストラクタを使用して、MenuItem クラスの新しいインスタンスを作成する方法のコード例を次に示します。その後、MenuItem オブジェクトを使用して、Menu コントロールのメニュー項目が動的に設定されます。
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not IsPostBack Then ' Create the menu structure. ' Create the root menu item. Dim homeMenuItem As New MenuItem("Home", "Root") ' Create the submenu items. Dim musicSubMenuItem As New MenuItem("Music", "Category 1") Dim moviesSubMenuItem As New MenuItem("Movies", "Category 2") ' Add the submenu items to the ChildItems ' collection of the root menu item. homeMenuItem.ChildItems.Add(musicSubMenuItem) homeMenuItem.ChildItems.Add(moviesSubMenuItem) ' Add the root menu item to the Items collection ' of the Menu control. NavigationMenu.Items.Add(homeMenuItem) End If End Sub </script> <html> <body> <form runat="server"> <h3>MenuItem Constructor Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void Page_Load(Object sender, EventArgs e) { if (!IsPostBack) { // Create the menu structure. // Create the root menu item. MenuItem homeMenuItem = new MenuItem("Home", "Root"); // Create the submenu items. MenuItem musicSubMenuItem = new MenuItem("Music", "Category 1"); MenuItem moviesSubMenuItem = new MenuItem("Movies", "Category 2"); // Add the submenu items to the ChildItems // collection of the root menu item. homeMenuItem.ChildItems.Add(musicSubMenuItem); homeMenuItem.ChildItems.Add(moviesSubMenuItem); // Add the root menu item to the Items collection // of the Menu control. NavigationMenu.Items.Add(homeMenuItem); } } </script> <html> <body> <form runat="server"> <h3>MenuItem Constructor Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"/> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItem コンストラクタ (MenuMerge, Int32, Shortcut, String, EventHandler, EventHandler, EventHandler, MenuItem[])
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Public Sub New ( _ mergeType As MenuMerge, _ mergeOrder As Integer, _ shortcut As Shortcut, _ text As String, _ onClick As EventHandler, _ onPopup As EventHandler, _ onSelect As EventHandler, _ items As MenuItem() _ )
Dim mergeType As MenuMerge Dim mergeOrder As Integer Dim shortcut As Shortcut Dim text As String Dim onClick As EventHandler Dim onPopup As EventHandler Dim onSelect As EventHandler Dim items As MenuItem() Dim instance As New MenuItem(mergeType, mergeOrder, shortcut, text, onClick, onPopup, onSelect, items)
public MenuItem ( MenuMerge mergeType, int mergeOrder, Shortcut shortcut, string text, EventHandler onClick, EventHandler onPopup, EventHandler onSelect, MenuItem[] items )
public: MenuItem ( MenuMerge mergeType, int mergeOrder, Shortcut shortcut, String^ text, EventHandler^ onClick, EventHandler^ onPopup, EventHandler^ onSelect, array<MenuItem^>^ items )
public MenuItem ( MenuMerge mergeType, int mergeOrder, Shortcut shortcut, String text, EventHandler onClick, EventHandler onPopup, EventHandler onSelect, MenuItem[] items )
public function MenuItem ( mergeType : MenuMerge, mergeOrder : int, shortcut : Shortcut, text : String, onClick : EventHandler, onPopup : EventHandler, onSelect : EventHandler, items : MenuItem[] )
- mergeType
MenuMerge 値の 1 つ。
- onPopup
このメニュー項目の Popup イベントを処理する EventHandler。
- onSelect
このメニュー項目の Select イベントを処理する EventHandler。

text パラメータを使用してメニュー項目のキャプションを指定するときに、アクセス キーも指定できます。指定する場合は、キャプションの末尾にアンパサンド (&) を追加し、その後にアクセス キーとして使用する英字を大文字で入力し、アンパサンドを含めて前後を () で囲みます。たとえば、"ファイル" メニューのアクセス キーとして "F" を指定するには、メニュー項目のキャプションを "ファイル(&F)" と指定します。この機能を使用すると、キーボードを使用してメニュー内を移動できます。
text パラメータを "-" に設定すると、メニュー項目が標準のメニュー項目ではなく、区分線 (水平線) として表示されます。
items パラメータを使用すると、メニュー項目の配列を割り当てて、メニュー項目のサブメニューを定義できます。配列内の各項目にも、メニュー項目の配列を割り当てることができます。これにより、完成度の高いメニュー構造を作成し、メニュー項目のコンストラクタに割り当てることができます。
mergeType パラメータと mergeOrder パラメータを使用すると、メニュー項目が別のメニューにマージされた場合に、そのメニュー項目がどのように動作するかを決定できます。mergeType パラメータに指定した値に応じて、メニュー項目とそのサブメニュー項目をマージ先のメニューに対して追加、削除、置換、またはマージできます。mergeOrder パラメータは、作成されているメニュー項目が、メニューがマージされた場合に配置される位置を決定します。
さらに、このコンストラクタを使用して MenuItem を作成し、そのメニュー項目のクリック イベントを処理するイベント ハンドラに結びつけることができます。このコンストラクタに渡す EventHandler は、Click イベントを処理できるイベント ハンドラを呼び出すように設定する必要があります。このバージョンのコンストラクタを使用すると、Popup イベントと Select イベントを結び付けることもでき、メニュー項目がいつ選択されたのかを判断できます。これらのイベントは、サブメニュー項目の横にチェック マークを表示するかどうか、またはアプリケーションの状態に基づいてメニュー項目を有効にするか無効にするかなどを決定するタスクに対して使用できます。Select イベントと Click イベントは、親メニュー項目ではない MenuItem オブジェクトに対してだけ発生します。イベント処理の詳細については、「イベントとデリゲート」を参照してください。

キャプションとショートカット キーが指定されているメニュー項目を作成するコード例を次に示します。このメニュー項目には、Popup、Click、Select の各イベントに対して定義されているイベント ハンドラもあります。このメニュー項目がマージされる場合、この項目はマージ順序 0 でメニューに追加されます。
Public Sub CreateMyMenuItem() ' Submenu item array. Dim SubMenus(3) as MenuItem ' Create three menu items to add to the submenu item array. Dim SubMenuItem1, SubMenuItem2, SubMenuItem3 as MenuItem SubMenuItem1 = New MenuItem ("Red") SubMenuItem2 = New MenuItem ("Blue") SubMenuItem3 = New MenuItem ("Green") ' Add the submenu items to the array. SubMenus(0) = SubMenuItem1 SubMenus(1) = SubMenuItem2 SubMenus(2) = SubMenuItem3 ' Create a MenuItem with caption, shortcut key, ' a Click, Popup, and Select event handler, menu merge type and order, and an ' array of submenu items specified. Dim MenuItem1 As MenuItem MenuItem1 = New MenuItem(MenuMerge.Add, 0, Shortcut.CtrlShiftC, "&Colors", _ AddressOf Me.MenuItem1_Click, _ AddressOf Me.MenuItem1_Popup, _ AddressOf Me.MenuItem1_Select, SubMenus) End Sub ' The following method is an event handler for MenuItem1 to use when connecting the Click event. Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e as System.EventArgs) ' Code goes here that handles the Click event. End Sub ' The following method is an event handler for MenuItem1 to use when connecting the Popup event. Private Sub MenuItem1_Popup(ByVal sender As System.Object, ByVal e as System.EventArgs) ' Code goes here that handles the Click event. End Sub ' The following method is an event handler for MenuItem1 to use when connecting the Select event Private Sub MenuItem1_Select(ByVal sender As System.Object, ByVal e as System.EventArgs) ' Code goes here that handles the Click event. End Sub
public void CreateMyMenuItem() { // Submenu item array. MenuItem[] subMenus = new MenuItem[3]; // Create three menu items to add to the submenu item array. MenuItem subMenuItem1 = new MenuItem("Red"); MenuItem subMenuItem2 = new MenuItem("Blue"); MenuItem subMenuItem3 = new MenuItem("Green"); // Add the submenu items to the array. subMenus[0] = subMenuItem1; subMenus[1] = subMenuItem2; subMenus[2] = subMenuItem3; /* Create a MenuItem with caption, shortcut key, a Click, Popup, and Select event handler, merge type and order, and an array of submenu items specified. */ MenuItem menuItem1 = new MenuItem(MenuMerge.Add, 0, Shortcut.CtrlShiftC, "&Colors", new EventHandler(this.MenuItem1_Click) , new EventHandler(this.MenuItem1_Popup) , new EventHandler(this.MenuItem1_Select), subMenus); } // The following method is an event handler for menuItem1 to use when connecting the Click event. private void MenuItem1_Click(Object sender, EventArgs e) { // Code goes here that handles the Click event. } // The following method is an event handler for menuItem1 to use when connecting the Popup event. private void MenuItem1_Popup(Object sender, EventArgs e) { // Code goes here that handles the Click event. } // The following method is an event handler for menuItem1 to use when connecting the Select event private void MenuItem1_Select(Object sender, EventArgs e) { // Code goes here that handles the Click event. }
public: void CreateMyMenuItem() { // Submenu item array. array<MenuItem^>^ subMenus = gcnew array<MenuItem^>(3); // Create three menu items to add to the submenu item array. MenuItem^ subMenuItem1 = gcnew MenuItem( "Red" ); MenuItem^ subMenuItem2 = gcnew MenuItem( "Blue" ); MenuItem^ subMenuItem3 = gcnew MenuItem( "Green" ); // Add the submenu items to the array. subMenus[ 0 ] = subMenuItem1; subMenus[ 1 ] = subMenuItem2; subMenus[ 2 ] = subMenuItem3; /* Create a MenuItem with caption, shortcut key, a Click, Popup, and Select event handler, merge type and order, and an array of submenu items specified. */ MenuItem^ menuItem1 = gcnew MenuItem( MenuMerge::Add, 0, Shortcut::CtrlShiftC, "&Colors", gcnew EventHandler( this, &Form1::MenuItem1_Click ), gcnew EventHandler( this, &Form1::MenuItem1_Popup ), gcnew EventHandler( this, &Form1::MenuItem1_Select ), subMenus ); } private: // The following method is an event handler for menuItem1 to use when connecting the Click event. void MenuItem1_Click( Object^ sender, EventArgs^ e ) { // Code goes here that handles the Click event. } // The following method is an event handler for menuItem1 to use when connecting the Popup event. void MenuItem1_Popup( Object^ sender, EventArgs^ e ) { // Code goes here that handles the Click event. } // The following method is an event handler for menuItem1 to use when connecting the Select event void MenuItem1_Select( Object^ sender, EventArgs^ e ) { // Code goes here that handles the Click event. }
public void CreateMyMenuItem() { // Submenu item array. MenuItem subMenus[] = new MenuItem[3]; // Create three menu items to add to the submenu item array. MenuItem subMenuItem1 = new MenuItem("Red"); MenuItem subMenuItem2 = new MenuItem("Blue"); MenuItem subMenuItem3 = new MenuItem("Green"); // Add the submenu items to the array. subMenus.set_Item(0,subMenuItem1); subMenus.set_Item(1,subMenuItem2); subMenus.set_Item(2,subMenuItem3); /* Create a MenuItem with caption, shortcut key, a Click, Popup, and Select event handler, merge type and order, and an array of submenu items specified. */ MenuItem menuItem1 = new MenuItem(MenuMerge.Add, 0, Shortcut.CtrlShiftC, "&Colors", new EventHandler(this.menuItem1_Click) , new EventHandler(this.menuItem1_Popup) , new EventHandler(this.menuItem1_Select), subMenus); } //CreateMyMenuItem // The following method is an event handler for menuItem1 to use // when connecting the Click event. private void menuItem1_Click(Object sender, EventArgs e) { // Code goes here that handles the Click event. } //menuItem1_Click // The following method is an event handler for menuItem1 to use // when connecting the Popup event. private void menuItem1_Popup(Object sender, EventArgs e) { // Code goes here that handles the Click event. } //menuItem1_Popup // The following method is an event handler for menuItem1 to use // when connecting the Select event private void menuItem1_Select(Object sender, EventArgs e) { // Code goes here that handles the Click event. } //menuItem1_Select

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItem コンストラクタ (String, String, String)
アセンブリ: System.Web (system.web.dll 内)

Dim text As String Dim value As String Dim imageUrl As String Dim instance As New MenuItem(text, value, imageUrl)

このコンストラクタを使用して、text パラメータで指定されたメニュー テキスト、value パラメータで指定された値、および imageUrl パラメータで指定されたイメージの URL で、MenuItem クラスの新しいインスタンスを作成します。
MenuItem クラスのインスタンスの初期プロパティ値を次の表に示します。
このコンストラクタは、Menu コントロールの Items コレクションまたは MenuItem オブジェクトの ChildItems コレクションを動的に設定する場合によく使用されます。

このコンストラクタを使用して、MenuItem クラスの新しいインスタンスを作成する方法のコード例を次に示します。その後、MenuItem オブジェクトを使用して、Menu コントロールのメニュー項目が動的に設定されます。
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not IsPostBack Then ' Create the menu structure. ' Create the root menu item. Dim homeMenuItem As New MenuItem("Home", "Root", _ "Images\Home.jpg") ' Create the submenu items. Dim musicSubMenuItem As New MenuItem("Music", "Category 1", _ "Images\Music.jpg") Dim moviesSubMenuItem As New MenuItem("Movies", "Category 2", _ "Images\Movies.jpg") ' Add the submenu items to the ChildItems ' collection of the root menu item. homeMenuItem.ChildItems.Add(musicSubMenuItem) homeMenuItem.ChildItems.Add(moviesSubMenuItem) ' Add the root menu item to the Items collection ' of the Menu control. NavigationMenu.Items.Add(homeMenuItem) End If End Sub </script> <html> <body> <form runat="server"> <h3>MenuItem Constructor Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void Page_Load(Object sender, EventArgs e) { if (!IsPostBack) { // Create the menu structure. // Create the root menu item. MenuItem homeMenuItem = new MenuItem("Home", "Root", @"Images\Home.jpg"); // Create the submenu items. MenuItem musicSubMenuItem = new MenuItem("Music", "Category 1", @"Images\Music.jpg"); MenuItem moviesSubMenuItem = new MenuItem("Movies", "Category 2", @"Images\Movies.jpg"); // Add the submenu items to the ChildItems // collection of the root menu item. homeMenuItem.ChildItems.Add(musicSubMenuItem); homeMenuItem.ChildItems.Add(moviesSubMenuItem); // Add the root menu item to the Items collection // of the Menu control. NavigationMenu.Items.Add(homeMenuItem); } } </script> <html> <body> <form runat="server"> <h3>MenuItem Constructor Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"/> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItem コンストラクタ (String, String, String, String, String)
アセンブリ: System.Web (system.web.dll 内)

Public Sub New ( _ text As String, _ value As String, _ imageUrl As String, _ navigateUrl As String, _ target As String _ )
Dim text As String Dim value As String Dim imageUrl As String Dim navigateUrl As String Dim target As String Dim instance As New MenuItem(text, value, imageUrl, navigateUrl, target)
public: MenuItem ( String^ text, String^ value, String^ imageUrl, String^ navigateUrl, String^ target )
public function MenuItem ( text : String, value : String, imageUrl : String, navigateUrl : String, target : String )

このコンストラクタを使用して、text パラメータで指定されたメニュー テキスト、value パラメータで指定された値、imageUrl パラメータで指定されたイメージの URL、navigateUrl パラメータで指定されたナビゲーション URL、および target パラメータで指定された表示先で、MenuItem クラスの新しいインスタンスを作成します。
MenuItem クラスのインスタンスの初期プロパティ値を次の表に示します。
このコンストラクタは、Menu コントロールの Items コレクションまたは MenuItem オブジェクトの ChildItems コレクションを動的に設定する場合によく使用されます。

このコンストラクタを使用して、MenuItem クラスの新しいインスタンスを作成する方法のコード例を次に示します。その後、MenuItem オブジェクトを使用して、Menu コントロールのメニュー項目が動的に設定されます。
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not IsPostBack Then ' Create the menu structure. ' Create the root menu item. Dim homeMenuItem As New MenuItem("Home", "Root", _ "Images\Home.jpg", "Home.aspx", "_self") ' Create the submenu items. Dim musicSubMenuItem As New MenuItem("Music", "Category 1", _ "Images\Music.jpg", "Music.aspx", "_blank") Dim moviesSubMenuItem As New MenuItem("Movies", "Category 2", _ "Images\Movies.jpg", "Movies.aspx", "_blank") ' Add the submenu items to the ChildItems ' collection of the root menu item. homeMenuItem.ChildItems.Add(musicSubMenuItem) homeMenuItem.ChildItems.Add(moviesSubMenuItem) ' Add the root menu item to the Items collection ' of the Menu control. NavigationMenu.Items.Add(homeMenuItem) End If End Sub </script> <html> <body> <form runat="server"> <h3>MenuItem Constructor Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void Page_Load(Object sender, EventArgs e) { if (!IsPostBack) { // Create the menu structure. // Create the root menu item. MenuItem homeMenuItem = new MenuItem("Home", "Root" , @"Images\Home.jpg", "Home.aspx", "_self"); // Create the submenu items. MenuItem musicSubMenuItem = new MenuItem("Music", "Category 1", @"Images\Music.jpg", "Music.aspx", "_blank"); MenuItem moviesSubMenuItem = new MenuItem("Movies", "Category 2", @"Images\Movies.jpg", "Movies.aspx", "_blank"); // Add the submenu items to the ChildItems // collection of the root menu item. homeMenuItem.ChildItems.Add(musicSubMenuItem); homeMenuItem.ChildItems.Add(moviesSubMenuItem); // Add the root menu item to the Items collection // of the Menu control. NavigationMenu.Items.Add(homeMenuItem); } } </script> <html> <body> <form runat="server"> <h3>MenuItem Constructor Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" runat="server"/> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItem コンストラクタ (String)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


text パラメータを使用してメニュー項目のキャプションを指定するときに、アクセス キーも指定できます。指定する場合は、キャプションの末尾にアンパサンド (&) を追加し、その後にアクセス キーとして使用する英字を大文字で入力し、アンパサンドを含めて前後を () で囲みます。たとえば、"ファイル" メニューのアクセス キーとして "F" を指定するには、メニュー項目のキャプションを "ファイル(&F)" と指定します。この機能を使用すると、キーボードを使用してメニュー内を移動できます。
text パラメータを "-" に設定すると、メニュー項目が標準のメニュー項目ではなく、区分線 (水平線) として表示されます。

MenuItem を作成するときに、そのメニュー項目のキャプションを指定するコード例を次に示します。
Public Sub CreateMyMenus() ' Create an instance of a MenuItem with a specified caption. menuItem1 = New MenuItem("&File") End Sub
public void CreateMyMenus() { // Create an instance of a MenuItem with a specified caption. menuItem1 = new MenuItem("&File"); }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItem コンストラクタ (String, EventHandler)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


text パラメータを使用してメニュー項目のキャプションを指定するときに、アクセス キーも指定できます。指定する場合は、キャプションの末尾にアンパサンド (&) を追加し、その後にアクセス キーとして使用する英字を大文字で入力し、アンパサンドを含めて前後を () で囲みます。たとえば、"ファイル" メニューのアクセス キーとして "F" を指定するには、メニュー項目のキャプションを "ファイル(&F)" と指定します。この機能を使用すると、キーボードを使用してメニュー内を移動できます。
text パラメータを "-" に設定すると、メニュー項目が標準のメニュー項目ではなく、区分線 (水平線) として表示されます。
さらに、このコンストラクタを使用して、作成しているメニュー項目の Click イベントを処理するデリゲートを指定できます。このコンストラクタに渡す EventHandler は、Click イベントを処理できるイベント ハンドラを呼び出すように設定する必要があります。イベント処理の詳細については、「イベントとデリゲート」を参照してください。

指定したキャプション、およびメニュー項目の Click イベントを処理するイベント ハンドラに関連付けられた EventHandler デリゲートを使用して、MenuItem オブジェクトを作成するコード例を次に示します。
Public Sub CreateMyMenuItem() ' Create an instance of MenuItem with caption and an event ' handler Dim MenuItem1 As New MenuItem("&New", New _ System.EventHandler(AddressOf Me.MenuItem1_Click)) End Sub ' This method is an event handler for MenuItem1 to use when ' connecting its event handler. Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal _ e as System.EventArgs) ' Code goes here that handles the Click event. End Sub
public void CreateMyMenuItem() { // Create an instance of MenuItem with caption and an event handler MenuItem menuItem1 = new MenuItem("&New", new System.EventHandler(this.MenuItem1_Click)); } // This method is an event handler for menuItem1 to use when connecting its event handler. private void MenuItem1_Click(Object sender, System.EventArgs e) { // Code goes here that handles the Click event. }
public: void CreateMyMenuItem() { // Create an instance of MenuItem with caption and an event handler MenuItem^ menuItem1 = gcnew MenuItem( "&New",gcnew System::EventHandler( this, &Form1::MenuItem1_Click ) ); } private: // This method is an event handler for menuItem1 to use when connecting its event handler. void MenuItem1_Click( Object^ sender, System::EventArgs^ e ) { // Code goes here that handles the Click event. }
public void CreateMyMenuItem() { // Create an instance of MenuItem with caption and an event handler MenuItem menuItem1 = new MenuItem("&New", new System.EventHandler(this.menuItem1_Click)); } //CreateMyMenuItem // This method is an event handler for menuItem1 to use // when connecting its event handler. private void menuItem1_Click(Object sender, System.EventArgs e) { // Code goes here that handles the Click event. } //menuItem1_Click

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItem コンストラクタ (String, MenuItem[])
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


text パラメータを使用してメニュー項目のキャプションを指定するときに、アクセス キーも指定できます。指定する場合は、キャプションの末尾にアンパサンド (&) を追加し、その後にアクセス キーとして使用する英字を大文字で入力し、アンパサンドを含めて前後を () で囲みます。たとえば、"ファイル" メニューのアクセス キーとして "F" を指定するには、メニュー項目のキャプションを "ファイル(&F)" と指定します。この機能を使用すると、キーボードを使用してメニュー内を移動できます。
text パラメータを "-" に設定すると、メニュー項目が標準のメニュー項目ではなく、区分線 (水平線) として表示されます。
items パラメータを使用すると、メニュー項目の配列を割り当てて、メニュー項目のサブメニューを定義できます。配列内の各項目にも、メニュー項目の配列を割り当てることができます。これにより、完成度の高いメニュー構造を作成し、メニュー項目のコンストラクタに割り当てることができます。

指定したキャプション、サブメニュー項目の配列内の各メニュー項目のイベントを処理するメソッドに関連付けられているイベント ハンドラを使用して、オブジェクトを作成するコード例を次に示します。
Public Sub CreateMyMenuItem() ' submenu item array. Dim subMenus(3) As MenuItem ' Create three menu items to add to the submenu item array. Dim subMenuItem1 As New MenuItem("Red") Dim subMenuItem2 As New MenuItem("Blue") Dim subMenuItem3 As New MenuItem("Green") ' Add the submenu items to the array. subMenus(0) = subMenuItem1 subMenus(1) = subMenuItem2 subMenus(2) = subMenuItem3 ' Create an instance of a MenuItem with caption and an array of submenu ' items specified. Dim MenuItem1 As New MenuItem("&Colors", subMenus) End Sub
public void CreateMyMenuItem() { // submenu item array. MenuItem[] subMenus = new MenuItem[3]; // Create three menu items to add to the submenu item array. MenuItem subMenuItem1 = new MenuItem("Red"); MenuItem subMenuItem2 = new MenuItem("Blue"); MenuItem subMenuItem3 = new MenuItem("Green"); // Add the submenu items to the array. subMenus[0] = subMenuItem1; subMenus[1] = subMenuItem2; subMenus[2] = subMenuItem3; // Create an instance of a MenuItem with caption and an array of submenu // items specified. MenuItem MenuItem1 = new MenuItem("&Colors", subMenus); }
public: void CreateMyMenuItem() { // submenu item array. array<MenuItem^>^ subMenus = gcnew array<MenuItem^>(3); // Create three menu items to add to the submenu item array. MenuItem^ subMenuItem1 = gcnew MenuItem( "Red" ); MenuItem^ subMenuItem2 = gcnew MenuItem( "Blue" ); MenuItem^ subMenuItem3 = gcnew MenuItem( "Green" ); // Add the submenu items to the array. subMenus[ 0 ] = subMenuItem1; subMenus[ 1 ] = subMenuItem2; subMenus[ 2 ] = subMenuItem3; // Create an instance of a MenuItem with caption and an array of submenu // items specified. MenuItem^ MenuItem1 = gcnew MenuItem( "&Colors",subMenus ); }
public void CreateMyMenuItem() { // submenu item array. MenuItem subMenus[] = new MenuItem[3]; // Create three menu items to add to the submenu item array. MenuItem subMenuItem1 = new MenuItem("Red"); MenuItem subMenuItem2 = new MenuItem("Blue"); MenuItem subMenuItem3 = new MenuItem("Green"); // Add the submenu items to the array. subMenus.set_Item(0, subMenuItem1); subMenus.set_Item(1, subMenuItem2); subMenus.set_Item(2, subMenuItem3); // Create an instance of a MenuItem with caption and an array of // submenu items specified. MenuItem menuItem1 = new MenuItem("&Colors", subMenus); } //CreateMyMenuItem

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItem コンストラクタ (String, EventHandler, Shortcut)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim text As String Dim onClick As EventHandler Dim shortcut As Shortcut Dim instance As New MenuItem(text, onClick, shortcut)

text パラメータを使用してメニュー項目のキャプションを指定するときに、アクセス キーも指定できます。指定する場合は、キャプションの末尾にアンパサンド (&) を追加し、その後にアクセス キーとして使用する英字を大文字で入力し、アンパサンドを含めて前後を () で囲みます。たとえば、"ファイル" メニューのアクセス キーとして "F" を指定するには、メニュー項目のキャプションを "ファイル(&F)" と指定します。この機能を使用すると、キーボードを使用してメニュー内を移動できます。また、このコンストラクタを使用して、アクセス キーに加えてショートカット キーも指定すると、キーボード操作によって項目間を移動できるようになります。ショートカット キーには複数のキーを組み合わせて指定でき、これらのキーを使用して特定のメニュー項目をアクティブにすることができます。
text パラメータを "-" に設定すると、メニュー項目が標準のメニュー項目ではなく、区分線 (水平線) として表示されます。
さらに、このコンストラクタを使用して、作成しているメニュー項目の Click イベントを処理するデリゲートを指定できます。このコンストラクタに渡す EventHandler は、Click イベントを処理できるイベント ハンドラを呼び出すように設定する必要があります。イベント処理の詳細については、「イベントとデリゲート」を参照してください。

指定したキャプション、ショートカット キー、メニュー項目のイベントを処理するメソッドに関連付けられたイベント ハンドラを使用して、オブジェクトを作成するコード例を次に示します。
Public Sub CreateMyMenuItem() ' Create a MenuItem with caption, shortcut key, and an event handler ' specified. Dim MenuItem1 As New MenuItem("&New", _ New System.EventHandler(AddressOf Me.MenuItem1_Click), Shortcut.CtrlL) End Sub ' The following method is an event handler for menuItem1 to use when ' connecting the event handler. Private Sub MenuItem1_Click(sender As Object, e As EventArgs) ' Code goes here that handles the Click event. End Sub
public void CreateMyMenuItem() { // Create a MenuItem with caption, shortcut key, and an event handler // specified. MenuItem MenuItem1 = new MenuItem("&New", new System.EventHandler(this.MenuItem1_Click), Shortcut.CtrlL); } // The following method is an event handler for menuItem1 to use when // connecting the event handler. private void MenuItem1_Click(Object sender, EventArgs e) { // Code goes here that handles the Click event. }
public: void CreateMyMenuItem() { // Create a MenuItem with caption, shortcut key, and an event handler // specified. MenuItem^ MenuItem1 = gcnew MenuItem( "&New", gcnew System::EventHandler( this, &Form1::MenuItem1_Click ), Shortcut::CtrlL ); } private: // The following method is an event handler for menuItem1 to use when // connecting the event handler. void MenuItem1_Click( Object^ sender, EventArgs^ e ) { // Code goes here that handles the Click event. }
public void CreateMyMenuItem() { // Create a MenuItem with caption, shortcut key, and an event handler // specified. MenuItem menuItem1 = new MenuItem("&New", new System.EventHandler (this.menuItem1_Click), Shortcut.CtrlL); } //CreateMyMenuItem // The following method is an event handler for menuItem1 to use when // connecting the event handler. private void menuItem1_Click(Object sender, EventArgs e) { // Code goes here that handles the Click event. } //menuItem1_Click

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItem コンストラクタ (String)
アセンブリ: System.Web (system.web.dll 内)


このコンストラクタを使用して、text パラメータで指定されたメニュー テキストで MenuItem クラスの新しいインスタンスを作成し、初期化します。
MenuItem クラスのインスタンスの初期プロパティ値を次の表に示します。
このコンストラクタは、Menu コントロールの Items コレクションまたは MenuItem オブジェクトの ChildItems コレクションを動的に設定する場合によく使用されます。

このコンストラクタを使用して、MenuItem クラスの新しいインスタンスを作成する方法のコード例を次に示します。その後、MenuItem オブジェクトを使用して、Menu コントロールのメニュー項目が動的に設定されます。
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not IsPostBack Then ' Create the menu structure. ' Create the root menu item. Dim homeMenuItem As New MenuItem("Home") ' Create the submenu items. Dim musicSubMenuItem As New MenuItem("Music") Dim moviesSubMenuItem As New MenuItem("Movies") ' Add the submenu items to the ChildItems ' collection of the root menu item. homeMenuItem.ChildItems.Add(musicSubMenuItem) homeMenuItem.ChildItems.Add(moviesSubMenuItem) ' Add the root menu item to the Items collection ' of the Menu control. NavigationMenu.Items.Add(homeMenuItem) End If End Sub </script> <html> <body> <form runat="server"> <h3>MenuItem Constructor Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void Page_Load(Object sender, EventArgs e) { if (!IsPostBack) { // Create the menu structure. // Create the root menu item. MenuItem homeMenuItem = new MenuItem("Home"); // Create the submenu items. MenuItem musicSubMenuItem = new MenuItem("Music"); MenuItem moviesSubMenuItem = new MenuItem("Movies"); // Add the submenu items to the ChildItems // collection of the root menu item. homeMenuItem.ChildItems.Add(musicSubMenuItem); homeMenuItem.ChildItems.Add(moviesSubMenuItem); // Add the root menu item to the Items collection // of the Menu control. NavigationMenu.Items.Add(homeMenuItem); } } </script> <html> <body> <form runat="server"> <h3>MenuItem Constructor Example</h3> <asp:menu id="NavigationMenu" orientation="Vertical" target="_blank" runat="server"/> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MenuItem コンストラクタ

名前 | 説明 |
---|---|
MenuItem () | メニュー テキストまたは値を指定せずに、MenuItem クラスの新しいインスタンスを初期化します。 |
MenuItem (String) | メニュー テキストを指定して、MenuItem クラスの新しいインスタンスを初期化します。 |
MenuItem (String, String) | メニュー テキストと値を指定して、MenuItem クラスの新しいインスタンスを初期化します。 |
MenuItem (String, String, String) | メニュー テキスト、値、イメージの URL を指定して、MenuItem クラスの新しいインスタンスを初期化します。 |
MenuItem (String, String, String, String) | メニュー テキスト、値、イメージの URL、およびナビゲーション URL を指定して、MenuItem クラスの新しいインスタンスを初期化します。 |
MenuItem (String, String, String, String, String) | メニュー テキスト、値、イメージの URL、ナビゲーション URL、および表示先を指定して、MenuItem クラスの新しいインスタンスを初期化します。 |

MenuItem プロパティ


名前 | 説明 | |
---|---|---|
![]() | System.Web.UI.IStateManager.IsTrackingViewState | MenuItem オブジェクトがビューステートへの変更を保存しているかどうかを示す値を取得します。 |

MenuItem プロパティ


名前 | 説明 | |
---|---|---|
![]() | CanRaiseEvents | コンポーネントがイベントを発生させることがきるかどうかを示す値を取得します。 ( Component から継承されます。) |
![]() | DesignMode | Component が現在デザイン モードかどうかを示す値を取得します。 ( Component から継承されます。) |
![]() | Events | Component に結び付けられているイベント ハンドラのリストを取得します。 ( Component から継承されます。) |
![]() | MenuID | メニュー項目の Windows 識別子を示す値を取得します。 |

MenuItem メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | System.ICloneable.Clone | 現在の MenuItem オブジェクトのコピーを作成します。 |
![]() | System.Web.UI.IStateManager.LoadViewState | メニュー項目が前回保存したビューステートを読み込みます。 |
![]() | System.Web.UI.IStateManager.SaveViewState | ビューステートの変更を Object に保存します。 |
![]() | System.Web.UI.IStateManager.TrackViewState | ビューステートへの変更を追跡するように MenuItem オブジェクトに指示します。 |

MenuItem メソッド


名前 | 説明 | |
---|---|---|
![]() | CloneMenu | オーバーロードされます。 MenuItem のコピーを作成します。 |
![]() | CreateMenuHandle | Menu への新しいハンドルを作成します。 ( Menu から継承されます。) |
![]() | Dispose | オーバーロードされます。 オーバーライドされます。 |
![]() | Finalize | Component がガベージ コレクションによってクリアされる前に、アンマネージ リソースを解放し、その他のクリーンアップ操作を実行します。 ( Component から継承されます。) |
![]() | FindMergePosition | メニューにおけるメニュー項目の追加位置を返します。 ( Menu から継承されます。) |
![]() | GetService | Component またはその Container で提供されるサービスを表すオブジェクトを返します。 ( Component から継承されます。) |
![]() | MemberwiseClone | オーバーロードされます。 ( MarshalByRefObject から継承されます。) |
![]() | OnClick | Click イベントを発生させます。 |
![]() | OnDrawItem | DrawItem イベントを発生させます。 |
![]() | OnInitMenuPopup | Popup イベントを発生させます。 |
![]() | OnMeasureItem | MeasureItem イベントを発生させます。 |
![]() | OnPopup | Popup イベントを発生させます。 |
![]() | OnSelect | Select イベントを発生させます。 |
![]() | ProcessCmdKey | コマンド キーを処理します。 ( Menu から継承されます。) |

MenuItem メンバ
Menu コントロールに表示されるメニュー項目を表します。このクラスは継承できません。
MenuItem データ型で公開されるメンバを以下の表に示します。



名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | System.ICloneable.Clone | 現在の MenuItem オブジェクトのコピーを作成します。 |
![]() | System.Web.UI.IStateManager.LoadViewState | メニュー項目が前回保存したビューステートを読み込みます。 |
![]() | System.Web.UI.IStateManager.SaveViewState | ビューステートの変更を Object に保存します。 |
![]() | System.Web.UI.IStateManager.TrackViewState | ビューステートへの変更を追跡するように MenuItem オブジェクトに指示します。 |
![]() | System.Web.UI.IStateManager.IsTrackingViewState | MenuItem オブジェクトがビューステートへの変更を保存しているかどうかを示す値を取得します。 |

MenuItem メンバ
MainMenu または ContextMenu 内に表示される個別の項目を表します。ToolStripMenuItem は以前のバージョンの MenuItem コントロールの機能を置換または追加しますが、選択により、下位互換性および将来の使用のために MenuItem を保持することもできます。
MenuItem データ型で公開されるメンバを以下の表に示します。



名前 | 説明 | |
---|---|---|
![]() | CanRaiseEvents | コンポーネントがイベントを発生させることがきるかどうかを示す値を取得します。(Component から継承されます。) |
![]() | DesignMode | Component が現在デザイン モードかどうかを示す値を取得します。(Component から継承されます。) |
![]() | Events | Component に結び付けられているイベント ハンドラのリストを取得します。(Component から継承されます。) |
![]() | MenuID | メニュー項目の Windows 識別子を示す値を取得します。 |


名前 | 説明 | |
---|---|---|
![]() | CloneMenu | オーバーロードされます。 MenuItem のコピーを作成します。 |
![]() | CreateMenuHandle | Menu への新しいハンドルを作成します。 (Menu から継承されます。) |
![]() | Dispose | オーバーロードされます。 オーバーライドされます。 |
![]() | Finalize | Component がガベージ コレクションによってクリアされる前に、アンマネージ リソースを解放し、その他のクリーンアップ操作を実行します。 (Component から継承されます。) |
![]() | FindMergePosition | メニューにおけるメニュー項目の追加位置を返します。 (Menu から継承されます。) |
![]() | GetService | Component またはその Container で提供されるサービスを表すオブジェクトを返します。 (Component から継承されます。) |
![]() | MemberwiseClone | オーバーロードされます。 ( MarshalByRefObject から継承されます。) |
![]() | OnClick | Click イベントを発生させます。 |
![]() | OnDrawItem | DrawItem イベントを発生させます。 |
![]() | OnInitMenuPopup | Popup イベントを発生させます。 |
![]() | OnMeasureItem | MeasureItem イベントを発生させます。 |
![]() | OnPopup | Popup イベントを発生させます。 |
![]() | OnSelect | Select イベントを発生させます。 |
![]() | ProcessCmdKey | コマンド キーを処理します。 (Menu から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Click | メニュー項目に対して定義されているショートカット キーまたはアクセス キーを使用して、そのメニュー項目がクリックまたは選択されると発生します。 |
![]() | Disposed | コンポーネントの Disposed イベントを待機するイベント ハンドラを追加します。(Component から継承されます。) |
![]() | Select | ユーザーがメニュー項目の上にポインタを置いた場合に発生します。 |

- MenuItemのページへのリンク