Вам необходимо добавить FlowLayoutPanel
к вашему Form
, а затем добавить к нему строки, как показано ниже:
private void AddRow()
{
//First create and setup your controls that are supposed to be in a row:
ComboBox cb1 = new ComboBox(){ /* settings */ };
// Other Controls
//Then add them to the FlowLayoutPanel:
flowLayoutPanel1.Controls.Add(cb1);
// add other controls
// Then set a line break at the end of row:
flowLayoutPanel1.SetFlowBreak(cb4, true); // let's say cb4 is the last control of the row.
}
Тогда вы можете использовать метод следующим образом:
int numRows;
bool success = int.TryParse(textBox1.text, out numRows); // lets say textBox1 contains number of rows.
if(success)
{
for(int i = 0; i < numRows; i++)
{
AddRow();
}
}