DataGridViewRowContextMenuStripNeededEventArgs.ContextMenuStrip プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGridViewRowContextMenuStripNeededEventArgs.ContextMenuStrip プロパティの意味・解説 

DataGridViewRowContextMenuStripNeededEventArgs.ContextMenuStrip プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

RowContextMenuStripNeeded イベントの発生元である行のショートカット メニュー取得または設定します

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

Public Property ContextMenuStrip As
 ContextMenuStrip
Dim instance As DataGridViewRowContextMenuStripNeededEventArgs
Dim value As ContextMenuStrip

value = instance.ContextMenuStrip

instance.ContextMenuStrip = value
public ContextMenuStrip ContextMenuStrip { get;
 set; }
public:
property ContextMenuStrip^ ContextMenuStrip {
    ContextMenuStrip^ get ();
    void set (ContextMenuStrip^ value);
}
/** @property */
public ContextMenuStrip get_ContextMenuStrip ()

/** @property */
public void set_ContextMenuStrip (ContextMenuStrip
 value)
public function get ContextMenuStrip
 () : ContextMenuStrip

public function set ContextMenuStrip
 (value : ContextMenuStrip)

プロパティ
使用されている ContextMenuStrip。

解説解説

このプロパティ初期値は、行の DataGridViewRow.ContextMenuStrip プロパティ設定されている場合、そのプロパティの値です。

使用例使用例

RowContextMenuStripNeeded イベント処理して従業員役職応じた ContextMenuStrip表示するコード例次に示します。この例では、2 種類ショートカット メニューがあり、1 つ経営者向け、もう 1 つその他のすべての従業員向けです。この例は DataGridViewRowContextMenuStripNeededEventArgs クラス概要取り上げているコード例一部です。

Public Sub dataGridView1_RowContextMenuStripNeeded(
 _
    ByVal sender As Object,
 _
    ByVal e As DataGridViewRowContextMenuStripNeededEventArgs)
 _
    Handles dataGridView1.RowContextMenuStripNeeded

    Dim dataGridViewRow1 As DataGridViewRow
 = _
    dataGridView1.Rows(e.RowIndex)

    toolStripMenuItem1.Enabled = True

    ' Show the appropriate ContextMenuStrip based on the employees title.
    If dataGridViewRow1.Cells("Title").Value.ToString()
 = _
        "Sales Manager" OrElse
 _
        dataGridViewRow1.Cells("Title").Value.ToString()
 = _
        "Vice President, Sales" Then

        e.ContextMenuStrip = managerMenuStrip
    Else
        e.ContextMenuStrip = employeeMenuStrip
    End If

    contextMenuRowIndex = e.RowIndex
End Sub
void dataGridView1_RowContextMenuStripNeeded(object sender,
    DataGridViewRowContextMenuStripNeededEventArgs e)
{
    DataGridViewRow dataGridViewRow1 = dataGridView1.Rows[e.RowIndex];

    toolStripMenuItem1.Enabled = true;

    // Show the appropriate ContextMenuStrip based on the employees
 title.
    if ((dataGridViewRow1.Cells["Title"].Value.ToString()
 ==
        "Sales Manager") ||
        (dataGridViewRow1.Cells["Title"].Value.ToString() ==
        "Vice President, Sales"))
    {
        e.ContextMenuStrip = managerMenuStrip;
    }
    else
    {
        e.ContextMenuStrip = employeeMenuStrip;
    }

    contextMenuRowIndex = e.RowIndex;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewRowContextMenuStripNeededEventArgs クラス
DataGridViewRowContextMenuStripNeededEventArgs メンバ
System.Windows.Forms 名前空間
ContextMenuStrip クラス
DataGridView クラス
DataGridView.RowContextMenuStripNeeded イベント
DataGridViewRow.ContextMenuStrip プロパティ



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

辞書ショートカット

すべての辞書の索引

「DataGridViewRowContextMenuStripNeededEventArgs.ContextMenuStrip プロパティ」の関連用語

DataGridViewRowContextMenuStripNeededEventArgs.ContextMenuStrip プロパティのお隣キーワード
検索ランキング

   

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



DataGridViewRowContextMenuStripNeededEventArgs.ContextMenuStrip プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS