private string GenerateControl(string templateText, List<string> fields, ContoleType ctrType) { string temp = templateText; x = 0; y = 0; foreach (string t in fields) { string text = t.ToString().Trim(); //..................................................................................... //..................................................................................... //Define Label //..................................................................................... temp = temp.Replace("//##Components0##", addNewLblCtr.Replace("#val#", "lbl" + text) + Environment.NewLine + "//##Components0##"); temp = temp.Replace("//##Components0##", addLblOptions.Replace("#nameVal#", "lbl" + text) .Replace("#textVal#", text) .Replace("#x#", x.ToString()) .Replace("#y#", y.ToString()) .Replace("#widthVal#", (text.Length + 5).ToString()) + ";" + Environment.NewLine + "//##Components0##"); UpdateSize(text.Length, ref x, ref y); temp = temp.Replace("//##DefComponents##", defLblCtr + "lbl" + text + ";" + Environment.NewLine + "//##DefComponents##"); temp = temp.Replace("//##Components##", addCtr + "lbl" + text + ");" + Environment.NewLine + "//##Components##"); //Define ComboBox //..................................................................................... if (ctrType == ContoleType.Combo) { temp = temp.Replace("//##Components0##", addNewCmbCtr.Replace("#val#", "cmb" + text) + Environment.NewLine + "//##Components0##"); temp = temp.Replace("//##Components0##", addCmbOptions.Replace("#nameVal#", "cmb" + text) .Replace("#x#", x.ToString()) .Replace("#y#", y.ToString()) + ";" + Environment.NewLine + "//##Components0##"); UpdateSize(text.Length + 100, ref x, ref y); temp = temp.Replace("//##DefComponents##", defCmbCtr + "cmb" + text + ";" + Environment.NewLine + "//##DefComponents##"); temp = temp.Replace("//##Components##", addCtr + "cmb" + text + ");" + Environment.NewLine + "//##Components##"); } //..................................................................................... //Define CheckBox //..................................................................................... if (ctrType == ContoleType.CheckBox) { temp = temp.Replace("//##Components0##", addNewChCtr.Replace("#val#", "ch" + text) + Environment.NewLine + "//##Components0##"); temp = temp.Replace("//##Components0##", addChOptions.Replace("#nameVal#", "ch" + text) .Replace("#x#", x.ToString()) .Replace("#y#", y.ToString()) + ";" + Environment.NewLine + "//##Components0##"); UpdateSize(text.Length + 100, ref x, ref y); temp = temp.Replace("//##DefComponents##", defChCtr + "ch" + text + ";" + Environment.NewLine + "//##DefComponents##"); temp = temp.Replace("//##Components##", addCtr + "ch" + text + ");" + Environment.NewLine + "//##Components##"); } //..................................................................................... //Define TextBox //..................................................................................... if (ctrType == ContoleType.Text) { temp = temp.Replace("//##Components0##", addNewTxtCtr.Replace("#val#", "txt" + text) + Environment.NewLine + "//##Components0##"); temp = temp.Replace("//##Components0##", addTxtOptions.Replace("#nameVal#", "txt" + text) .Replace("#x#", x.ToString()) .Replace("#y#", y.ToString()) + ";" + Environment.NewLine + "//##Components0##"); UpdateSize(text.Length + 100, ref x, ref y); temp = temp.Replace("//##DefComponents##", defTxtCtr + "txt" + text + ";" + Environment.NewLine + "//##DefComponents##"); temp = temp.Replace("//##Components##", addCtr + "txt" + text + ");" + Environment.NewLine + "//##Components##"); } //..................................................................................... } return temp; }
private string GenerateControl(string templateText, List <string> fields, ContoleType ctrType) { string temp = templateText; x = 0; y = 0; foreach (string t in fields) { string text = t.ToString().Trim(); //..................................................................................... //..................................................................................... //Define Label //..................................................................................... temp = temp.Replace("//##Components0##", addNewLblCtr.Replace("#val#", "lbl" + text) + Environment.NewLine + "//##Components0##"); temp = temp.Replace("//##Components0##", addLblOptions.Replace("#nameVal#", "lbl" + text) .Replace("#textVal#", text) .Replace("#x#", x.ToString()) .Replace("#y#", y.ToString()) .Replace("#widthVal#", (text.Length + 5).ToString()) + ";" + Environment.NewLine + "//##Components0##"); UpdateSize(text.Length, ref x, ref y); temp = temp.Replace("//##DefComponents##", defLblCtr + "lbl" + text + ";" + Environment.NewLine + "//##DefComponents##"); temp = temp.Replace("//##Components##", addCtr + "lbl" + text + ");" + Environment.NewLine + "//##Components##"); //Define ComboBox //..................................................................................... if (ctrType == ContoleType.Combo) { temp = temp.Replace("//##Components0##", addNewCmbCtr.Replace("#val#", "cmb" + text) + Environment.NewLine + "//##Components0##"); temp = temp.Replace("//##Components0##", addCmbOptions.Replace("#nameVal#", "cmb" + text) .Replace("#x#", x.ToString()) .Replace("#y#", y.ToString()) + ";" + Environment.NewLine + "//##Components0##"); UpdateSize(text.Length + 100, ref x, ref y); temp = temp.Replace("//##DefComponents##", defCmbCtr + "cmb" + text + ";" + Environment.NewLine + "//##DefComponents##"); temp = temp.Replace("//##Components##", addCtr + "cmb" + text + ");" + Environment.NewLine + "//##Components##"); } //..................................................................................... //Define CheckBox //..................................................................................... if (ctrType == ContoleType.CheckBox) { temp = temp.Replace("//##Components0##", addNewChCtr.Replace("#val#", "ch" + text) + Environment.NewLine + "//##Components0##"); temp = temp.Replace("//##Components0##", addChOptions.Replace("#nameVal#", "ch" + text) .Replace("#x#", x.ToString()) .Replace("#y#", y.ToString()) + ";" + Environment.NewLine + "//##Components0##"); UpdateSize(text.Length + 100, ref x, ref y); temp = temp.Replace("//##DefComponents##", defChCtr + "ch" + text + ";" + Environment.NewLine + "//##DefComponents##"); temp = temp.Replace("//##Components##", addCtr + "ch" + text + ");" + Environment.NewLine + "//##Components##"); } //..................................................................................... //Define TextBox //..................................................................................... if (ctrType == ContoleType.Text) { temp = temp.Replace("//##Components0##", addNewTxtCtr.Replace("#val#", "txt" + text) + Environment.NewLine + "//##Components0##"); temp = temp.Replace("//##Components0##", addTxtOptions.Replace("#nameVal#", "txt" + text) .Replace("#x#", x.ToString()) .Replace("#y#", y.ToString()) + ";" + Environment.NewLine + "//##Components0##"); UpdateSize(text.Length + 100, ref x, ref y); temp = temp.Replace("//##DefComponents##", defTxtCtr + "txt" + text + ";" + Environment.NewLine + "//##DefComponents##"); temp = temp.Replace("//##Components##", addCtr + "txt" + text + ");" + Environment.NewLine + "//##Components##"); } //..................................................................................... } return(temp); }