المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Passing Value From One Form To Another! [modified]



C# Programming
03-31-2010, 08:01 AM
Hi,
I am trying to pass value from one windows form to another in desktop application using C#.
I have created two text boxes on Form1 and a button, on button click I am creating Form2 and From2 contains one button, on this button click I have to pass value from Form2 to Form1 textboxes.

I have created Properties in Form1.

public string Emp
{
get
{
return strEmp;
}
set
{
strEmp = value;
}
}

public string EmpID
{
get
{
return strEmpID;
}
set
{
strEmpID = value;
}
}


And on Form1 button click:

private void button1_Click(object sender, EventArgs e)
{
Form2 fr = new Form2();

this.textBox1.Text = strEmp ;
this.textBox2.Text = strEmpID ;
fr.ShowDialog();
}


On Form2:

private void button1_Click(object sender, EventArgs e)
{
Form1 fr = new Form1();
fr. Emp = "Alex";
fr. EmpID = "1121";
this.Close();
}

This code is not working, Please let me know where I am wrong.

Thanks,
modified on Wednesday, March 31, 2010 12:54 AM