Hi,
How to retrieve the winform controls from another Form?
For Example i have winForm named as sample1,in which i want to write code for to retrieve controls of another form named as Sample2?
Is It Possible?
How to use control.controlcollection.find(formname)?
Thanks
Subash
Loading
Kirtan PatelPosted Jul 30, 2009, 7:39 AM
Here i have Taken 2 Forms Sample1 and Sample 2 From Sample 1 We can launch Sample 2 When we launch Sample2 It Changes the TextBox Text in Sample1 to "Hello "
private void Sample2_Load(object sender, EventArgs e)
{
FormCollection coll = Application.OpenForms;
foreach (Form f in coll)
{
if (f.Name == "Sample1")
{
Control[] t = f.Controls.Find("textBox1", true);
((TextBox)(t[0])).Text = "Hello";
}
}
}
Happy Coding :)