DataGridViewRow.GetContextMenuStrip Method (Int32)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets the shortcut menu for the row.

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

public ContextMenuStrip GetContextMenuStrip(
	int rowIndex


Type: System.Int32

The index of the current row.

Return Value

Type: System.Windows.Forms.ContextMenuStrip

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

Exception Condition

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.

.NET Framework
Available since 2.0
Return to top