Ok i am a beginner at this and wondered the same thing. I believe I understand what you're asking. I just tried this and after a few attempts it clicked, and being newer to this maybe I can simplify it with my words. I don't know which program you are using but I used Visual Studio 2016. I created two forms(Form1 and Form2) each containing a button. Form1 button and Form2 button. When I click Form1 button it calls a method from form2, and when I click Form2 button it calls a method from Form1. I noticed that in the solution explorer it shows both forms, and everything they contain. I've done a lot of research and correct me if I am wrong but I believe the order goes like this from parent container to child( Namespace>Class>Method ). Believing this to be true I figured that I would need to call the class before I could call the method.
These are my scripts.
Form1 :
public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Form2 frm2 = new Form2(); frm2.Show(); } private void f1button_Click(object sender, EventArgs e) { f2Words f2w = new f2Words(); f2w.Words2(); } } public class f1Words { public void Words1() { MessageBox.Show("Form 1 Method Calling Worked!"); } }
Form2:
public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { } private void f2button_Click(object sender, EventArgs e) { f1Words f1w = new f1Words(); f1w.Words1(); } } public class f2Words { public void Words2() { MessageBox.Show("Form 2 Method Calling Worked!"); } }
In the Solution Explorer window it shows the classes of both Form1 and Form2. So I decided to try to call new instances of these classes.
"f1Words f1w = new f1words()" and "f2Words f2w = new f2Words()".
Then right after this I called those new instances of the classes into play with the methods they contained.
"f1w.Words1()" and "f2w.Words2()"
The end result was a success. When I click Form1's Button1 it called Form2's F2Words Class and pulled the Words2 Method out of it opening a message box saying "Form2 Method Calling Worked!", and visa versa for the Form2 Button2.
As this post is 4 years old I assume you've already found this out on your own and perhaps found a better solution, but for anyone else asking this same question in the future I hope this helps you out.