title: Handling Enter key in DataGridView
body: <p>I have a datagridview having 5 columns. Columns in datagridview are [Item Code, Description, Quantity,Price &amp; Total].</p>
  
  <p><strong>How it Should Work:</strong>
  When a user enters itemcode, the description and price should fetch from database and displays the result in respective fields. Then the quantity should be entered by user.</p>
  
  <p><strong>WHAT I WANT:</strong> 
  I want when user enters value in 1st column(Item Code), the next cell to be selected should be the 3rd column(Quantity). Then if the quantity is entered and user presses the enter button, the next cell selected should be the 1st column(Item Code) of the next row. </p>
  
  <p><strong>PROBLEM:</strong> 
  I have tried several codes but its not working. The problem is when an item code is entered in the 1st column(Item Code), the position of the next cell is the  <strong>2nd Row</strong> of the 3rd column(Quantity). It should move to the 3rd column(Quantity) of the same row <strong>i.e the 1st Row</strong>.  </p>
  
  <p>Below is my code that I have used:</p>
  
  <pre><code>private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
      {
          currentRow = dataGridView1.CurrentCell.RowIndex;
          currentColumn = dataGridView1.CurrentCell.ColumnIndex;
  
      }
  
  private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
      {
  
          if (currentColumn == dataGridView1.Columns.Count - 5)
          {                
              dataGridView1.CurrentCell = dataGridView1[currentColumn + 2, currentRow];
  
          }
          else
          {
              dataGridView1.CurrentCell = dataGridView1[currentColumn - 2, currentRow + 1];
          }
      }
  </code></pre>