private void GenerateButton_Click(object sender, EventArgs e) { //GenerateButton try { int ChildNumberOfColumns = int.Parse(ConfigurationManager.AppSettings["ChildNumberOfColumns"]); string ChildColumnNames = ConfigurationManager.AppSettings["ChildColumnNames"]; List <string> ColumnNamesList = new List <string>(ConfigurationManager.AppSettings["ChildColumnNames"].Split(',')); int pointX = 80; int pointY = 40; MyPanel.Controls.Clear(); for (int i = 0; i < ChildNumberOfColumns; i++) { TextBox a = new TextBox(); a.Width = 200; a.Name = ColumnNamesList[i].ToString(); a.Text = ColumnNamesList[i].ToString(); a.Location = new Point(pointX, pointY); MyPanel.Controls.Add(a); MyPanel.Show(); pointY += 45; } } catch (Exception) { MessageBox.Show(e.ToString()); } }