Csharp: FlowLayoutPanel, csharp
/// <Summary> /// add control method /// </summary> /// <returns> </returns> public System. windows. forms. textBox AddNewTextBox () {Point p = new Point (); System. windows. forms. comboBox cmb = new ComboBox (); cmb. dataSource = setCmb (); cmb. valueMember = "id"; cmb. displayMember = "name"; this. controls. add (cmb); cmb. top = cLeft * 25; cmb. size = new System. drawing. size (121, 20); cmb. left = 2; flowLayoutPanel2.Controls. add (cmb); System. windows. forms. textBox txt = new System. windows. forms. textBox (); this. controls. add (txt); txt. top = cLeft * 25; txt. left = 200; txt. text = "TextBox" + this. cLeft. toString (); cLeft = cLeft + 1; flowLayoutPanel2.Controls. add (txt); return txt ;} /// <summary> /// add control /// </summary> /// <param name = "sender"> </param> /// <param name = "e"> </param> private void button#click (object sender, eventArgs e) {AddNewTextBox ();} /// <summary> /// obtain the control value // tu juwen 20150339 // Geovin Du /// </summary> /// <param name = "sender "> </param> // <param name =" e "> </param> private void button2_Click (object sender, eventArgs e) {// (TextBox) this. flowLayoutPanel2.Controls [2]). text = "geovindu"; // set the value // string s = (TextBox) this. flowLayoutPanel2.Controls [2]). text. trim (); // MessageBox. show (s); string s = string. empty; for (int I = 0; I <flowLayoutPanel2.Controls. count; I ++) {if (flowLayoutPanel2.Controls [I]. getType () = typeof (TextBox) {s = s + (TextBox) this. flowLayoutPanel2.Controls [I]). text. trim () + ";" ;}} MessageBox. show (s); foreach (Control control in flowLayoutPanel2.Controls) {if (control. getType () = typeof (ComboBox) // query by type {ComboBox cb = control as ComboBox; // convert to a specific control type cb. selectedText. toString ();} // if (control. name = "combox2") // find the control of a Name // {// MessageBox. show ("I Am a control named pictureBox2 ");//}}}