We can Pass Information from One Form to another Form
via an Overloaded Constructor.
In form1,we have to pass value in constructor on Object Creation.
Ex:
Form2 f2 = new Form2(UserName);
f2.ShowDialog();
Then in Form2,we have to assign Passed value in a Local variable or control.
Here UserName refers a String Variable which contains User Name entered in form1.
Ex:
String uname;
public Form2(String username)
{
InitializeComponent();
textBox1.Text =username ;
uname=username;
}
Now textBox1 & variable uname contains value Entered in Form1
Thank you.
No comments:
Post a Comment