---
title: "How to get the Index of Currently Selected Row in DataGridView using C#"  
description: "How to get the Index of Currently Selected Row in DataGridView using C#"  
author: "Mark Devid"  
published: 2013-10-05  
updated: 2013-10-05  
canonical: https://www.mindstick.com/forum/1584/how-to-get-the-index-of-currently-selected-row-in-datagridview-using-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How to get the Index of Currently Selected Row in DataGridView using C#

How do I get the [index](https://www.mindstick.com/blog/198/index-in-sql-server) of the currently selected [Row](https://www.mindstick.com/forum/1212/this-row-already-belongs-to-this-table) of a [DataGridView](https://www.mindstick.com/articles/607/working-with-datagridview-in-vc-sharp)?

I don't want the Row object, I want the index (0 .. n).

## Replies

### Reply by Dag Hammarskjold

There is the [RowIndex](http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcell.rowindex.aspx) property for the [CurrentCell](http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.currentcell.aspx) property for the DataGridView.

\

\

```
datagridview.CurrentCell.RowIndex
```

\

Handle the [SelectionChanged](http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.selectionchanged.aspx) event and find the index of the selected row as above.


---

Original Source: https://www.mindstick.com/forum/1584/how-to-get-the-index-of-currently-selected-row-in-datagridview-using-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
