Adding controls to TableLayoutPanel dynamically during runtime

前端 未结 1 486
温柔的废话
温柔的废话 2020-12-15 16:42

I have a TableLayoutPanel starting with two columns and 0 rows. What I need to do is, dynamically adding a row and filling both of the columns with different controls (it wi

相关标签:
1条回答
  • 2020-12-15 16:58

    Use something like this:

    Table.Controls.Add(new Label { Text = "Type:", Anchor = AnchorStyles.Left, AutoSize = true }, 0, 0);
    Table.Controls.Add(new ComboBox { Dock = DockStyle.Fill }, 0, 1);
    

    You don't need to define number of rows and columns, they will be added automatically.

    0 讨论(0)
提交回复
热议问题