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
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Mar 26, 2013, 7:28 AM EDT
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();
Violeta Popa132 reputationPosted Mar 26, 2013, 7:42 AM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 26, 2013, 7:51 AM EDT