title: Dynamic control in c#
body: <p>I want to create a kind of 4 x 3 matrix with textboxes and checkboxes. Whether the element is checkbox or textbox depends upon the values in database.I want it to be dynamic. What is the best way to start? </p>
  
  <pre><code>// something like this but I need to fill in each elements of the matrix...
    private void CreateSpecificControl(string requestedType)
          {
                  if (requestedType == "CheckBox")
                  {
  
                      CheckBox control1 = new CheckBox();
  
                      control1.Click += new EventHandler(chk_CheckedChanged);
  
                     //TableLayout panel
                      layout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25));
                      layout.Controls.Add(control1);
  
                  }
                  else
                  {
                      Label control1 = new Label();
  
                      control1.Text = "Not a checkbox";
                      layout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25));
                      layout.Controls.Add(control1);
  
                  }
  
          }
  </code></pre>