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

Dim instance As DataGridViewBand Dim value As ContextMenuStrip value = instance.ContextMenuStrip instance.ContextMenuStrip = value
public: virtual 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)
現在の DataGridViewBand に関連付けられている ContextMenuStrip。既定値は null 参照 (Visual Basic では Nothing) です。

ユーザーがバンドの表示領域でマウスの右ボタンをクリックすると、ショートカット メニューが表示されます。表示領域は、DataGridView 内の DataGridViewColumn または DataGridViewRow です。

DataGridViewColumn の ContextMenuStrip プロパティを使用して、セルの背景色を変更するための機能を追加するコード例を次に示します。このコード例は、DataGridViewColumn クラスのトピックで取り上げているコード例の一部分です。
WithEvents toolStripItem1 As New ToolStripMenuItem() Private Sub AddContextMenu() toolStripItem1.Text = "Redden" Dim strip As New ContextMenuStrip() For Each column As DataGridViewColumn _ In dataGridView.Columns() column.ContextMenuStrip = strip column.ContextMenuStrip.Items.Add(toolStripItem1) Next End Sub ' Change the cell's color. Private Sub toolStripItem1_Click(ByVal sender As Object, _ ByVal args As EventArgs) _ Handles toolStripItem1.Click dataGridView.Rows(mouseLocation.RowIndex) _ .Cells(mouseLocation.ColumnIndex) _ .Style.BackColor = Color.Red End Sub Private mouseLocation As DataGridViewCellEventArgs ' Deal with hovering over a cell. Private Sub dataGridView_CellMouseEnter(ByVal sender As Object, _ ByVal location As DataGridViewCellEventArgs) _ Handles DataGridView.CellMouseEnter mouseLocation = location End Sub
ToolStripMenuItem toolStripItem1 = new ToolStripMenuItem(); private void AddContextMenu() { toolStripItem1.Text = "Redden"; toolStripItem1.Click += new EventHandler(toolStripItem1_Click); ContextMenuStrip strip = new ContextMenuStrip(); foreach (DataGridViewColumn column in dataGridView.Columns) { column.ContextMenuStrip = strip; column.ContextMenuStrip.Items.Add(toolStripItem1); } } private DataGridViewCellEventArgs mouseLocation; // Change the cell's color. private void toolStripItem1_Click(object sender, EventArgs args) { dataGridView.Rows[mouseLocation.RowIndex] .Cells[mouseLocation.ColumnIndex].Style.BackColor = Color.Red; } // Deal with hovering over a cell. private void dataGridView_CellMouseEnter(object sender, DataGridViewCellEventArgs location) { mouseLocation = location; }

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


Weblioに収録されているすべての辞書からDataGridViewBand.ContextMenuStrip プロパティを検索する場合は、下記のリンクをクリックしてください。

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