title: DataGridView TextBox cell Editing, Change Enter Key to Act Like Tab
body: <p>I am re-asking this question as I now have some code to go with my issue (I deleted the old Question).</p>
  
  <p>Basically when the enter key is pressed while editing a textbox cell, I would like it to act like a Tab press (Next Column in current Row Instead of Next row same column).</p>
  
  <p>My problem is most of what I have tried so far doesn't work, This was my current attempted solution however.</p>
  
  <p>This code is supposed to change which cell is being edited/Selected.</p>
  
  <pre><code>    private void PreTranslateDGV_KeyPressEvent(object sender, KeyEventArgs e)
      {
          DataGridViewTextBoxEditingControl a = (DataGridViewTextBoxEditingControl) sender;
          //a.PreviewKeyDown -= PreviewKeyDownEventHandler (dataGridView1_PreviewKeyDown)
          MyDataGridView s = (MyDataGridView) a.EditingControlDataGridView;
          if (e.KeyCode == Keys.Enter)
          {
              e.SuppressKeyPress = true;
              int newRow;
              int newColumn;
              if (s.CurrentCell.ColumnIndex == s.ColumnCount - 1)         // it's a last column, move to next row;
              {
                  newRow = s.CurrentCell.RowIndex + 1;
                  newColumn = 0;
  
                  if (newRow == s.RowCount)
                      return; // ADD new row or RETURN (depends of your purposes..)
              }
              else                // just change current column. row is same
              {
                  newRow = s.CurrentCell.RowIndex;
                  newColumn = s.CurrentCell.ColumnIndex + 1;
              }
  
              s.CurrentCell = s.Rows[newRow].Cells[newColumn];
          }
      }
  </code></pre>
  
  <p>This is the code that Adds the Above event to the Cell's textbox</p>
  
  <pre><code>private void PreTranslateDGV_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
      {
          DataGridViewTextBoxEditingControl tb = (DataGridViewTextBoxEditingControl)e.Control;
          tb.KeyDown += new KeyEventHandler (PreTranslateDGV_KeyPressEvent);
      }
  </code></pre>
  
  <p>Most of this was code I found from StackOverflow as I have been trying to get it working for a while.</p>
  
  <p>If anyone Knows how to properly Get the "Enter" Keypress from within a datagridview, While editing a cell please help.</p>
  
  <p>PS: I Read on an MSDN forum (lost link) That when Editing a textbox cell, When you press enter it Stops editing. Which would explain why my code above doesn't fire On Enter, but it fires on everything else.</p>
  
  <p>I am now attempting to do this by over-riding the processcmdkey</p>
  
  <pre><code>    class MyDataGridView : KryptonDataGridView
  {
      protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
      {
          if ((keyData == Keys.Enter) &amp;&amp; (this.EditingControl != null))
          {
              return false;
          }
          //for the rest of the keys, proceed as normal
          return base.ProcessCmdKey(ref msg, keyData);
      }
  }
  </code></pre>
  
  <p>But no matter what I seem to Return, the Enter key isn't passed to the KeyPressEvent.</p>