title: DataGridView Copy Paste Multiple Columns
body: <p>I was wondering if someone could help me. I have wrote some some code that will copy from the Clipboard into a DatagridView. The issue that I am having is that everything works as it is suppose to except the first cell.</p>
  
  <p>For Example if I copy from Excel 2 columns only one row the value of 20 in the first column and the value of 30 in the second column</p>
  
  <p>Then when I paste it in the DataGridView I get the following. </p>
  
  <p>In the first column I get the number 20 and then a large space and the the value of 30 but in the second column only the value of 30 shows up.</p>
  
  <p>Below is my code id anyone has an idea on how to fix that first cell please help me</p>
  
  <pre><code> if (e.Control &amp;&amp; e.KeyCode == Keys.V)
          {
              char[] rowSplitter = { '\r', '\n' };
              char[] columnSplitter = { '\t' };
              //get the text from clipboard
              IDataObject dataInClipboard = Clipboard.GetDataObject();
              string stringInClipboard = (string)dataInClipboard.GetData(DataFormats.Text);
              //split it into lines
              string[] rowsInClipboard = stringInClipboard.Split(rowSplitter, StringSplitOptions.RemoveEmptyEntries);
              //get the row and column of selected cell in grid
              int r = DGV.SelectedCells[0].RowIndex;
              int c = DGV.SelectedCells[0].ColumnIndex;
              //add rows into grid to fit clipboard lines
              if (DGV.Rows.Count &lt; (r + rowsInClipboard.Length))
              {
                  MessageBox.Show("PasteValues Will be Outside of Grid");
                  return;
              }
              // loop through the lines, split them into cells and place the values in the corresponding cell.
              for (int iRow = 0; iRow &lt; rowsInClipboard.Length; iRow++)
              {
                  //split row into cell values
                  string[] valuesInRow = rowsInClipboard[iRow].Split(columnSplitter);
                  //cycle through cell values
                  for (int iCol = 0; iCol &lt; valuesInRow.Length; iCol++)
                  {
                      //assign cell value, only if it within columns of the grid
                      if (DGV.ColumnCount - 1 &gt;= c + iCol)
                      {
                          DGV.Rows[r + iRow].Cells[c + iCol].Value = valuesInRow[iCol];
                          for (int i = 0;
                          i &lt; selectedCellCount; i++)
                          {
                              DGV.SelectedCells[i].Value = valuesInRow[iCol]; ;
                          }
                      }
                  }
              }
  
          }
  </code></pre>