大家好,在winform程序中如何动态添加多个tablelayoutpanel啊,我添加的到最后只显示最后一条数据,前边的都找不到了,是不是因为被覆盖了呀?请高手指点一下。
大致代码如下:
for (int i = 0; i < dtQuestion.Rows.Count; i++)
{
   TableLayoutPanel tlpQuestion = new TableLayoutPanel();
   Label lblTitle = new Label();
   tlpQuestion.ColumnCount = 3;
   tlpQuestion.Controls.Add(lblTitle, 0, 0);
   int y = i * 2 + 20;
   tlpQuestion.Location = new System.Drawing.Point(12, y);
   this.Controls.Add(tlpQuestion);
}
想要的最终结果是:
标题:(label)       月末测试(label)
调查状态:(label)   问卷锁定中...(label)      结束调查(button)标题:(label)       年终测试(label)
调查状态:(label)   本次调查已结束(label)     继续调查(button)

解决方案 »

  1.   

    Location 设置不同的x,y
    Label 也设置不同location
      

  2.   


    我用
    int y = i * 2 + 20;
    tlpQuestion.Location = new System.Drawing.Point(12, y);
    已经对tablelayoutpanel进行的位置的设置。
      

  3.   

    你可以弄一个容器控件啊  然后把LABEL 在那个控件里面增加
    比如 panel
      

  4.   


    this.Controls.Add(tlpQuestion);
    直接将内容添加到窗体上去不行吗?
    再者我添加的label本来就是添加到tablelayoutpanel中的。
    那么label的位置应该随着tablelayoutpanel的位置呀。