Add label to Panel programmatically

旧时模样 提交于 2019-12-05 15:53:41

Add the panel just created to the Form.Controls collection

private void VizualizareTest_Load(object sender, EventArgs e)
{
    for (int i = 0; i < 4; i++)
    {
        Panel pan = new Panel();
        pan.Name = "panel" + i;
        ls.Add(pan);
        Label l = new Label();
        l.Text = "l"+i;
        pan.Location = new Point(10, i * 100);
        pan.Size = new Size(200, 90);  // just an example
        pan.Controls.Add(l);
        this.Controls.Add(pan);

    }
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!