title: Add row to DataGridView using Designer
body: <p>Is there a way to add rows to a dataGridView while in the visual designer? I have added this code, and the visual designer recognizes and displays the rows, but whenever I make a change, my code gets deleted. If I put this code in the non-designer portion of the partial class definition, then the designer doesn't visually show I have added these rows but at least it doesn't delete it when I make changes with the visual designer. </p>
  
  <p>It makes sense that the designer should delete and modify its code as necessary, but what is the right way to add a row so that it meets both requirements?</p>
  
  <ol>
  <li>Shows up in visual designer</li>
  <li>Isn't deleted upon changes in visual designer</li>
  </ol>
  
  <p>Either an answer explaining where to put the code or where to click in the designer is appreciated. If you can explain both, even better! Thanks!</p>
  
  <pre><code>this.dataGridView1.Rows.Add(9);
  this.dataGridView1.Rows[0].HeaderCell.Value = "L1";
  this.dataGridView1.Rows[1].HeaderCell.Value = "L2";
  </code></pre>
  
  <p>Here's an example of entering the code manually in the X.Designer.cs file</p>
  
  <pre><code>private void InitializeComponent()
          {
               // Other code here - from designer
               this.dataGridView1.Rows.Add(9);
          }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/OFNKi.png" alt="enter image description here"></p>
  
  <p>After doing anything with the visual designer tools, e.g. adding another column in the visual designer, the programatically entered code in the X.Designer.cs file is deleted. The rows are all gone.</p>
  
  <p><img src="https://i.stack.imgur.com/dEUCS.png" alt="enter image description here"></p>