ContextMenu コンストラクタ ()
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
このバージョンのコンストラクタを使用した後で、Menu.MenuItemCollection クラスの Add メソッドを使用して、ContextMenu にメニュー項目を追加できます。Menu.MenuItemCollection にアクセスするには、MenuItems プロパティを使用します。
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
ContextMenu コンストラクタ (MenuItem[])
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
public ContextMenu ( MenuItem[] menuItems )
public: ContextMenu ( array<MenuItem^>^ menuItems )
public ContextMenu ( MenuItem[] menuItems )
public function ContextMenu ( menuItems : MenuItem[] )
- menuItems
ショートカット メニューに追加するメニュー項目を表す MenuItem オブジェクトの配列。
このバージョンのコンストラクタを使用すると、指定したメニュー項目を作成時に保持している ContextMenu を作成できます。このバージョンのコンストラクタを使用した後で、Menu.MenuItemCollection クラスの Add メソッドを使用して、ContextMenu にメニュー項目を追加できます。Menu.MenuItemCollection にアクセスするには、MenuItems プロパティを使用します。
ショートカット メニューを構築し、Show メソッドを使用する方法を、次のコード例に示します。この例を実行するには、次のコードを、Button1 という名前のボタンが配置されているフォームに貼り付けます。必ずすべてのイベントをイベント処理メソッドに関連付けるようにしてください。
' Displays the shortcut menu, offsetting its location ' from the upper-left corner of Button1 by 20 pixels in each direction. Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click 'Declare the menu items and the shortcut menu. Dim menuItems() As MenuItem = New MenuItem() _ {New MenuItem("Some Button Info"), _ New MenuItem("Some Other Button Info"), _ New MenuItem("Exit")} Dim buttonMenu As New ContextMenu(menuItems) buttonMenu.Show(Button1, New System.Drawing.Point(20, 20)) End Sub
// Displays the shortcut menu, offsetting its location // from the upper-left corner of Button1 by 20 pixels in each direction. private void Button1_Click(System.Object sender, System.EventArgs e) { //Declare the menu items and the shortcut menu. MenuItem[] menuItems = new MenuItem[]{new MenuItem("Some Button Info"), new MenuItem("Some Other Button Info"), new MenuItem("Exit")}; ContextMenu buttonMenu = new ContextMenu(menuItems); buttonMenu.Show(Button1, new System.Drawing.Point(20, 20)); }
// Displays the shortcut menu, offsetting its location // from the upper-left corner of Button1 by 20 pixels in each direction. void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ ) { //Declare the menu items and the shortcut menu. array<MenuItem^>^menuItems = {gcnew MenuItem( "Some Button Info" ),gcnew MenuItem( "Some Other Button Info" ),gcnew MenuItem( "Exit" )}; System::Windows::Forms::ContextMenu^ buttonMenu = gcnew System::Windows::Forms::ContextMenu( menuItems ); buttonMenu->Show( Button1, System::Drawing::Point( 20, 20 ) ); }
// Displays the shortcut menu, offsetting its location // from the upper-left corner of Button1 by 20 pixels in each direction. private void button1_Click(Object sender, System.EventArgs e) { //Declare the menu items and the shortcut menu. MenuItem menuItems[] = new MenuItem[] { new MenuItem("Some Button Info"), new MenuItem("Some Other Button Info"), new MenuItem("Exit") }; ContextMenu buttonMenu = new ContextMenu(menuItems); buttonMenu.Show(button1, new System.Drawing.Point(20, 20)); } //button1_Click
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
ContextMenu コンストラクタ
Weblioに収録されているすべての辞書からContextMenu コンストラクタ ()を検索する場合は、下記のリンクをクリックしてください。
全ての辞書からContextMenu コンストラクタ ()を検索
- ContextMenu コンストラクタ ()のページへのリンク