DataGridViewRow.GetContextMenuStrip Method

Note: This method is new in the .NET Framework version 2.0.

Gets the shortcut menu for the row.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

public ContextMenuStrip GetContextMenuStrip (
	int rowIndex
public ContextMenuStrip GetContextMenuStrip (
	int rowIndex
public function GetContextMenuStrip (
	rowIndex : int
) : ContextMenuStrip



The index of the current row.

Return Value

A ContextMenuStrip that belongs to the DataGridViewRow at the specified index.

Exception typeCondition


rowIndex is -1.


rowIndex is less than zero or greater than or equal to the number of rows in the control minus one.

Pass the GetContextMenuStrip method the indexer you used to retrieve the DataGridViewRow. Do not use the Index property for the rowIndex parameter. If the row is shared, Index is -1, which is an invalid value for 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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions