title: DataGridView navigating to next row
body: <p>I have a C# winforms application and I am trying to get a button working that will select the next row in a datagridview after the one curently selected.</p>
  
  <p>The code I have so far is:</p>
  
  <pre><code>private void button4_Click(object sender, EventArgs e)
  {
    try
    {
      Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected);
  
      // index out of range on this line
      dataGridView1.Rows[dataGridView1.SelectedRows[selectedRowCount].Index].Selected = true;
  
      dataGridView1.FirstDisplayedScrollingRowIndex = selectedRowCount + 1;
    }
    catch (Exception ex)
    {
      return;
    }
  </code></pre>
  
  <p>But on running this it throws an exception. Could anyone point out where I may be going wrong. The thrown error is: <code>Index is out of range</code></p>