title: DataGridView get row values
body: <p>I am trying to get the cell values of the row that I clicked.</p>
  
  <p>here's my code..</p>
  
  <pre><code>private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
      {
          txtFullName.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
          txtUsername.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
          txtPassword.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
      }
  </code></pre>
  
  <p>works fine.. but it doesn't work when I click on the row(left side of the UserID) and on user id column... it also gives me an error when I click on the column header. how can I fix that error and I want it to also click on row and userid column.</p>
  
  <p><a href="https://i.stack.imgur.com/pQtYw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pQtYw.png" alt="enter image description here"></a></p>