title: How to add new row on click winforms
body: <p>I have a winforms application that I am developing, I have hit a dead end. What I am trying to do is on each "click", add a new row to my <code>DataTable</code> with the values input in the form. This <code>Datatable</code> is the DataSource for my <code>DataGridView</code>. Can someone point me in the right direction on how this can be achieved.</p>
  
  <p>Articles I looked at:</p>
  
  <p><a href="https://stackoverflow.com/questions/15965043/how-to-add-rows-to-datagridview-winforms">How to add new row to datatable gridview</a> </p>
  
  <p>My code:</p>
  
  <pre><code>private void btnAdd_Click(object sender, EventArgs e)
          {
          //inserting into order table
          DataTable dt = new DataTable();
  
          string articleId = cmbArticle.Text;
          string productDescription = txtDesc.Text;
          string type = txtType.Text;
          string materialType = txtMaterial.Text;
          string size = cmbSizes.Text;
          string quantity = txtQuantity.Text;
  
          try
          {
              dt.Columns.Add("Article");
              dt.Columns.Add("Description");
              dt.Columns.Add("Type");
              dt.Columns.Add("Material");
              dt.Columns.Add("Size");
              dt.Columns.Add("Quantity");
              dt.Columns.Add("DateTime");
  
              DataRow dr = dt.NewRow();
                  //addrows
                  dr["Article"] = articleId;
                  dr["Description"] = productDescription;
                  dr["type"] = type;
                  dr["Material"] = materialType;
                  dr["Size"] = size;
                  dr["Quantity"] = quantity;
  
              dt.Rows.Add(dr);
  
              dgvView.DataSource = dt;
          }
          catch (Exception ex)
          {
  
          }
      }
  </code></pre>