DataGridViewCell.RowIndex Property


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

Gets the index of the cell's parent row.

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

public int RowIndex { get; }

Property Value

Type: System.Int32

The index of the row that contains the cell; -1 if there is no owning row.

When the RowIndex property returns -1, the cell is either a column header, or the cell's row is shared.

For more information about row sharing, see Best Practices for Scaling the Windows Forms DataGridView Control.

The following code example illustrates the use of this property.

private void getCurrentCellButton_Click(object sender, System.EventArgs e)
    string msg = String.Format("Row: {0}, Column: {1}",
    MessageBox.Show(msg, "Current Cell");

.NET Framework
Available since 2.0
Return to top