Gets or sets the shortcut menu for the row.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
abstract ContextMenuStrip : ContextMenuStrip with get, set override ContextMenuStrip : ContextMenuStrip with get, set
This property indicates the shortcut menu that is displayed when the user right-clicks the row unless the DataGridView control CellContextMenuStripNeeded event or the row property overrides the shortcut menu for the specific cell that was clicked.
When the DataGridView control DataSource property is set or its VirtualMode property is true, getting the value of the property raises the RowContextMenuStripNeeded event of the control and returns the value of the DataGridViewRowContextMenuStripNeededEventArgs.ContextMenuStrip property as specified in the event handler. If there are no handlers for the event, getting the value of the property returns the previously specified value or its default value of a null reference (Nothing in Visual Basic).
Handling the RowContextMenuStripNeeded event is primarily useful when working with large amounts of data to avoid performance penalties when setting the row value for multiple rows. For more information, see Best Practices for Scaling the Windows Forms DataGridView Control.
If the current row is shared, use the GetContextMenuStrip method rather than getting the value of this property.
The following code example demonstrates how to use the DataGridViewColumn.ContextMenuStrip property, which is nearly identical to the property of the DataGridViewRow class. This code example is part of a larger code example provided in the DataGridViewColumn class.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.