title: How to end the DataGridView Cells Edit Mode automatically?
body: <p>this is a follow up question from my previous one. you can find it <a href="https://stackoverflow.com/questions/8708057/rows-cannot-be-programmatically-added-to-the-datagridviews-row-collection-when/8715407#8715407">here</a>.</p>
  
  <p>I got another problem after finally solving my previous one, when I assign the button to add the value into a new row in DataGrid, the entire cell will be on edit mode, until I clicked on other cell and filled it and/or tabbed till the end of the row (well apparently this one doesn't work), then it will end the edit mode. 
  I'm using <code>dataGridView.BeginEdit(true);</code> to begin the edit mode so that I could parse a value into the textbox (see my previous question). So, if I insert another value and press the button, the new value will replace the old value that was inserted previously because it is currently still on edit mode. 
  I was trying to use <code>dataGridView.EndEdit();</code>, <code>dataGridView.EndEdit(DataGridViewDataErrorContexts.Commit);</code>, <code>cell.DataGridView.EndEdit()</code> and <code>cell.DataGridView.EndEdit(DataGridViewDataErrorContexts.Commit);</code> but apparently that doesn't end the edit mode :( 
  What I wanted is when I press the button, the value inside the textbox will be inserted into the first textbox column (this one already worked). Then I don't have to click or fill the other column to end the edit mode. So, I'll just type anything into the textbox and press the button only until I wanted to stop. After that I begin to fill the other column. 
  does anyone know how to solve this? 
  <img src="https://i.stack.imgur.com/EhLTM.jpg" alt="sample image">
  <strong>EDIT 1: do you see the difference? look at the red circle, the top one is currently in edit mode (because it has a * after the arrow). the bottom one is not in edit mode (I did it manually by picking an item from the combobox).</strong> 
  Here is my code as requested from my previous question:</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
      {
          this.surat_jalanDataGridView.AllowUserToAddRows = true;
          string tokNum = this.textBox1.Text;
  
          if (this.textBox1.Text != "")
          {
              foreach (DataGridViewRow sjRow in this.surat_jalanDataGridView.Rows)
              {
                  int RowIndex = surat_jalanDataGridView.RowCount - 1;
                  DataGridViewRow R = surat_jalanDataGridView.Rows[RowIndex];
  
                  DataTable table = new DataTable();
                  DataRow newRow = table.NewRow();
                  table.Rows.Add(newRow);
  
                  DataGridViewCell cell = R.Cells[2];
                  this.surat_jalanDataGridView.CurrentCell = cell;
                  this.surat_jalanDataGridView.BeginEdit(true);
  
                  R.Cells[2].Value = tokNum;
                  cell.DataGridView.EndEdit(DataGridViewDataErrorContexts.Commit);
              }
          }
          this.surat_jalanDataGridView.EndEdit(DataGridViewDataErrorContexts.Commit);
      }
  </code></pre>
  
  <p><strong>EDIT 2: So, I drag and drop the surat_jalan from the data sources into my windows form. then it automatically become a datagrid with the property name <code>surat_jalanDataGridView</code> and the data source is <code>surat_jalanBindingSource</code></strong>
  <img src="https://i.stack.imgur.com/TwaG8.jpg" alt="img 2"></p>