ContextMenu コンストラクタとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ContextMenu コンストラクタの意味・解説 

ContextMenu コンストラクタ (MenuItem[])

一連の MenuItem オブジェクト指定してContextMenu クラス新しインスタンス初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Sub New ( _
    menuItems As MenuItem() _
)
Dim menuItems As MenuItem()

Dim instance As New ContextMenu(menuItems)
public ContextMenu (
    MenuItem[] menuItems
)
public:
ContextMenu (
    array<MenuItem^>^ menuItems
)
public ContextMenu (
    MenuItem[] menuItems
)
public function ContextMenu (
    menuItems : MenuItem[]
)

パラメータ

menuItems

ショートカット メニュー追加するメニュー項目を表す MenuItem オブジェクト配列

解説解説
使用例使用例

ショートカット メニュー構築し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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ContextMenu コンストラクタ


ContextMenu コンストラクタ ()

メニュー項目を指定せずに、ContextMenu クラス新しインスタンス初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説

このバージョンコンストラクタ使用した後で、Menu.MenuItemCollection クラスAdd メソッド使用してContextMenuメニュー項目を追加できますMenu.MenuItemCollectionアクセスするには、MenuItems プロパティ使用します

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からContextMenu コンストラクタを検索した結果を表示しています。
Weblioに収録されているすべての辞書からContextMenu コンストラクタを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からContextMenu コンストラクタを検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ContextMenu コンストラクタ」の関連用語

ContextMenu コンストラクタのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ContextMenu コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS