title: System Argument out of range exception in C# while adding rows to datagridview
body: <p>I have a code as follows:</p>
  
  <pre><code>private void svars_MouseDoubleClick(object sender, MouseEventArgs e)
          {
  
  
  
              userSelection user_sel = new userSelection();
              string file = svars.SelectedItem.ToString();
  
              DataGridViewRow row = new DataGridViewRow();
  
  
  
              dataGridView1.Rows.Add(row);
  
              row.Cells["Local_Variables"].Value = "test";
  
              DataGridViewCell sysvar = new DataGridViewTextBoxCell();
              sysvar.Value = file;
              row.Cells["System_Variables"] = sysvar;
  
          }
  </code></pre>
  
  <p>I am getting error following error:</p>
  
  <pre><code>An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in System.Windows.Forms.dll
  
  Additional information: Specified argument was out of the range of valid values.
  </code></pre>
  
  <p>When I tried to debug I found that row.Index is -1. I am not sure how to fix it. Can anyone please help.</p>
  
  <p>Thanks. </p>