calling a method from another form
hi :) i have form1 with the populate() method, and i want to call populate() in form2, how can i do that? plss
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Mar 26, 2013, 11:28 AM
If it's a static method, you can simply do:
Form1.populate();
If it's an instance method, you need a reference to the Form1 instance.
You can get a reference like this:
Form1 f1 = Application.OpenForms["Form1"] as Form1;
if (f1 != null) f1.populate();
VulpesPosted Mar 26, 2013, 11:51 AM
Violeta PopaPosted Mar 26, 2013, 11:42 AM