Form 1: Form Nhận giá Trị
private void button1_Click(object sender, EventArgs e)Form 2 : Form nhập Giá trị Và truyền sang Form 1
{
Form2 f2 = new Form2();/*Tạo Form 2 mới*/
f2.value = new Form2.Getstring(Getvalue);/*gán Giá Trị Từ Methol value cua form 2 sang getvalue cua form 1 */
f2.Show();/*Hiện Form 2*/
}
public void Getvalue(string s)
{
textBox1.Text = s;/*Gán Giá Trí chuỗi S(nhận giá trị từ bên form 2)vào textBox1*/
}
public delegate void Getstring ;/*Tạo Thư viện Getstring trong delegate */
public Getstring value;/*Tạo Methol Value Trong Thư Viện mới tạo Getstring*/
if (value != null)/*Điều kiện để Gán Giá Trị*/Note: public delegate void Getstring(string ten) ta có thể nhập nhiều giá trị cho thư viện Getstring như sau public delegate void Getstring(string ten,string d,int 5,.....)
value(textBox1.Text);/*Gán giá trị*/
Hình Minh hoạ