private void BuildGuiElements(String TableName) { // used to create GUIElements string GUIObjectName; dynamic GUIObject = null; // create all Forms, tabs and fields foreach (DataRow row in GlobalVar.DataSet.Tables[TableName].Rows) // Loop over the rows. { // compose GUIObjectName (field_[fieldID] ) GUIObjectName = TableName + "_" + row["id"].ToString(); // get Object to manage poolManager.GetObject(GUIObjectName, ref GUIObject); // check if objct need to be created if (null == GUIObject) { // create the object of correct class-type switch (TableName) { case "form": { GUIObject = new Form1(); break; } case "tab": { GUIObject = new TabPage(); break; } case "field": { switch (row["type"].ToString()) { case "Text": { GUIObject = new TextBox1(); break; } case "Button": { GUIObject = new Button1(); break; } case "Label": { GUIObject = new Label1(); break; } case "DataGridView": { GUIObject = new DataGridView1(); break; } default: { // column "type" has undefined Field Type break; } } break; } } // end switch // Add the new generated object to pool poolManager.AddObject(GUIObjectName, GUIObject); //MessageBox.Show(poolManager.CurrentObjectsInPool.ToString()); } //endif } // end loop }