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

Dim instance As DataGridViewCell 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)
セルに関連付けられた ContextMenuStrip。

このプロパティは通常、セルを右クリックしたときに表示されるショートカット メニューを示します。
DataGridView コントロールの DataSource プロパティが設定されている場合、または VirtualMode プロパティが true の場合、ContextMenuStrip プロパティの値を取得すると、コントロールの CellContextMenuStripNeeded イベントが発生し、イベント ハンドラに指定された DataGridViewCellContextMenuStripNeededEventArgs.ContextMenuStrip プロパティの値が返されます。イベントのハンドラがない場合、ContextMenuStrip プロパティの値を取得すると、以前に指定された値、またはその既定値である null 参照 (Visual Basic では Nothing) が返されます。
大量のデータを処理する場合、複数のセルにセルの ContextMenuStrip 値を設定する際のパフォーマンス低下を回避するには、まず CellContextMenuStripNeeded イベントの処理が有効です。詳細については、「Windows フォーム DataGridView コントロールを拡張するための推奨される手順」を参照してください。
このプロパティを変更すると、(存在すれば) そのセルを所有している DataGridView で CellContextMenuStripChanged イベントが発生します。
行の ContextMenuStrip プロパティを設定するか、DataGridView コントロールの RowContextMenuStripNeeded イベントを処理して、個別のセルではなく個別の行にショートカット メニューを指定することもできます。セルの ContextMenuStrip プロパティの設定は、行の ContextMenuStrip プロパティの設定をオーバーライドし、CellContextMenuStripNeeded イベントは、RowContextMenuStripNeeded イベントと行の ContextMenuStrip プロパティの設定の両方をオーバーライドします。ただし、セルのショートカット メニューに null 参照 (Visual Basic では Nothing) を指定すると、行のショートカット メニューがオーバーライドされるのを回避できます。

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


DataGridViewCell クラス
DataGridViewCell メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellContextMenuStripChanged イベント
DataGridView.CellContextMenuStripNeeded イベント
DataGridView.DataSource プロパティ
DataGridView.VirtualMode プロパティ
DataGridView.RowContextMenuStripNeeded イベント
DataGridViewRow.ContextMenuStrip
GetInheritedContextMenuStrip
ContextMenuStrip クラス
- DataGridViewCell.ContextMenuStrip プロパティのページへのリンク