title: DataGridView Column Template
body: <p>I have a DataGridView on my Form which is being populated with database records on the click event button.
  How can I populate another two column template programatically at run time?</p>
  
  <p>The two column template are <strong>Qty In Stock</strong> and <strong>Status</strong>
  This is my datagridview what looks like when populated from database on click event button...</p>
  
  <pre><code>===============================================================
  FoodName        FoodType     Qty In Stock     Status
  ===============================================================
  Olives          Starter                     
  Soup            Starter                     
  Caprese     Starter
  Bruschetta     Starter
  Mushroom     Starter
  Antipasto     Starter
  Scallops     Starter
  Calamari     Starter
  Crab Avocado    Starter
  Pizza Bread     Starter
  ===============================================================
  </code></pre>
  
  <p>And this is the datagridview what I want to look like populating the other two columns at the run-time</p>
  
  <pre><code>=================================================================
  FoodName        FoodType     Qty In Stock     Status
  =================================================================
  Olives          Starter      0                Allways On Stock
  Soup            Starter      0                Allways On Stock
  Caprese     Starter      0                Allways On Stock
  Bruschetta     Starter      0                Allways On Stock
  Mushroom     Starter      0                Allways On Stock
  Antipasto     Starter      0                Allways On Stock
  Scallops     Starter      0                Allways On Stock
  Calamari     Starter      0                Allways On Stock
  Crab Avocado    Starter      0                Allways On Stock
  Pizza Bread     Starter      0                Allways On Stock
  =================================================================
  </code></pre>
  
  <p>Here is the code generating the datagridview from database on click event button...</p>
  
  <pre><code>private DataGridViewTextBoxColumn ColFoodQtyStock = new DataGridViewTextBoxColumn();
          private DataGridViewTextBoxColumn ColFoodStatus = new DataGridViewTextBoxColumn();
  
          private void cmdStarters_Click(object sender, EventArgs e)
          {
              OleDbConnectionStringBuilder connBuilder = new OleDbConnectionStringBuilder();
              connBuilder.DataSource = @"C:\Users\AP_AE\Desktop\DTPOS_APP\DataBase\DtposMenu.accdb";
              connBuilder.Provider = "Microsoft.ACE.OLEDB.12.0";
              connBuilder.Add("Jet OLEDB:Engine Type", "5");
  
              // Food SQL Query
              string foodTypeSql = @"SELECT FoodName, FoodType FROM Food WHERE FoodType = @foodType";
              using (OleDbConnection conn = new OleDbConnection(connBuilder.ConnectionString))
              {
                  dataGridView1.Columns.Clear();
                  dataGridView1.RowTemplate.Height = 60;
                  //====================================\\
                  dataGridView1.Visible = true;
                  dataGridView2.Visible = false;
                  try
                  {
                      OleDbCommand foodsCommand = new OleDbCommand(foodTypeSql, conn);
                      OleDbParameter foodType = foodsCommand.Parameters.Add("@foodType", OleDbType.VarChar, 15);
                      OleDbDataAdapter foodsDa = new OleDbDataAdapter(foodsCommand);
                      //DataRow dr;
                      DataSet ds = new DataSet();
                      conn.Open();
                      foodType.Value = "Starter";
                      foodsDa.Fill(ds, "Food_table");
  
                      conn.Close();
                      dataGridView1.DataSource = ds;
                      dataGridView1.DataMember = "Food_table";
  
                      dataGridView1.Columns.AddRange(ColFoodQtyStock, ColFoodStatus);
  
                      DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle();
                      this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
                      dataGridViewCellStyle1.Font = new Font("Verdana", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  
                      this.dataGridView1.Columns[0].Width = 420;
                      this.dataGridView1.Columns[1].Width = 180;
                      this.dataGridView1.Columns[2].Width = 300;
                      this.dataGridView1.Columns[3].Width = 308;
  
                      // ColStatus 
                      ColFoodStatus.HeaderText = "Status";
                      ColFoodStatus.Name = "ColFoodStatus";
  
                      // ColQtyStock
                      ColFoodQtyStock.HeaderText = "Quantity In Stock";
                      ColFoodQtyStock.Name = "ColFoodQtyStock";
  
                  }
                  catch (Exception ex)
                  {
                      MessageBox.Show("Error: " + ex);
                  }
              }
          }
  </code></pre>
  
  <p>Could someone help me to modify the code on my click event button to solve this problem please</p>
  
  <p>Thanks in advance</p>
  
  <p>lapeci </p>