We Can access a Form's Control such as TextBox,ComboBox,datagridview etc. From another Form by passing current Form Object into another Form via an Overloaded constructor.
Ex:
In form 1
Form2 f1 = new Form2(this);
f1.ShowDialog();
then In Form2
Form1 form1;
public Form2(Form1 f)
{
InitializeComponent();
this.form1 = f;
}
we can easily access form1's TextBox like
form1.textBox1.Text="Hi,This is Form2";
Note : Modifiers property of Form1's TextBox1 should be declared as Public.
Thank you
No comments:
Post a Comment