Reputation: 435
I have a solution with multiple projects. Both the projects have Forms.
Example
MySolution
|____________________ Project1 (Windows Form)
|____________________ Project2 (Also a Windows Form)
Now I want to call the Form in Project2 from the Form in Project1. Sort of going like this
using (Form2 f2 = new Form2(myFile))
{
//....
}
Moving Form2 into Project1 is not an option unfortunately.
What's the best way to go about it.
Thanks
Upvotes: 1
Views: 1487
Reputation: 24606
You will need to add a reference from Project1 to Project2. This can be done by right-clicking on the project in the solution explorer and selecting "Add Reference". Once the window appears (it will take a moment), click on the projects tab and select the other project. Cyclic references are not allowed so Project1 can reference Project2 or vice-versa, but they can't both reference each other.
Good luck!
Upvotes: 0
Reputation: 24232
You need to reference the compiled Project2 dll or exe from Project1. Make sure Form2 is public, so Project 1 can see it. After that, you can create an instance of Form2 in Project1.
Upvotes: 0