title: how to insert the data into the table dynamically in windows form
body: <p>I need to display the result of an exam in a table, suppose I taken the test for one paper that result should be display in first row of table layout panel and if I taken test for one more paper that result should be display in second row of table layout panel dynamically using c# (if i click on store result button it should redirect to test result form and display the result) </p>
  
  <pre><code> public partial class Form3 : Form
  {
      private string papId;
      private string subject;
      private string chapter;
      private string tstname;
  
      public Form3(string papId,string tech,string subject,string chapter, string tstname,int maxMarks,int marksObtained)
      {
          InitializeComponent();
          this.papId=papId;
          this.subject=subject ;
          this.chapter = chapter;
          this.tstname = tstname;
          int row = dsplyUserReslt.Count;
          Label lblTech = getLabelDetails();
          lblTech.Text = tech;
          dsplyUserReslt.Controls.Add(lblTech, 0, row-1);
          Label lblSub = getLabelDetails();
          lblSub.Text = subject;
          dsplyUserReslt.Controls.Add(lblSub,1, row-1);
          Label lblChptr = getLabelDetails();
          lblChptr.Text = chapter;
          dsplyUserReslt.Controls.Add(lblChptr, 2, row-1);
          Label lbltstName = getLabelDetails();
          lbltstName.Text = tstname;
          dsplyUserReslt.Controls.Add(lbltstName, 3, row-1);
          Label lblmaxmarks = getLabelDetails();
          lblmaxmarks.Text = maxMarks.ToString();
          dsplyUserReslt.Controls.Add(lblmaxmarks, 4, row-1);
          Label lblmarksobtnd = getLabelDetails();
          lblmarksobtnd.Text = marksObtained.ToString();
          dsplyUserReslt.Controls.Add(lblmarksobtnd, 5, row - 1);
          Label date = getLabelDetails();
          date.Text = DateTime.Now.ToString("MMMM dd, yyyy");
          dsplyUserReslt.Controls.Add(date, 6, row - 1);
          Button btnImproveScore = new Button();
          btnImproveScore.Text = "improve score";
          btnImproveScore.Size = new System.Drawing.Size(135, 25);
          btnImproveScore.Font = new Font("Microsoft Sans Serif", 10);
          dsplyUserReslt.Controls.Add(btnImproveScore, 7, row - 1);
          btnImproveScore.Click+=new EventHandler(this.btnImproveScore_Click);
        if (row &gt; 4)
          { dsplyUserReslt.RowCount = 4; }
          else
          {
              dsplyUserReslt.RowCount = dsplyUserReslt.RowCount + 1;
              dsplyUserReslt.RowStyles.Clear();
              dsplyUserReslt.RowStyles.Add(new RowStyle(SizeType.Absolute, 120F));
          }
  
  
      }
     public Label getLabelDetails()
      {
          Label lbl = new Label();
          lbl.AutoSize = true;
          lbl.Font = new Font("Microsoft Sans Serif", 12);
          lbl.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
          return lbl;
      }
  </code></pre>