DataGridViewRowContextMenuStripNeededEventArgs.ContextMenuStrip プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As DataGridViewRowContextMenuStripNeededEventArgs Dim value As ContextMenuStrip value = instance.ContextMenuStrip instance.ContextMenuStrip = value
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。


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; }

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


- DataGridViewRowContextMenuStripNeededEventArgs.ContextMenuStrip プロパティのページへのリンク