If two project in an solution ,how to open one of the form from Project 1 through this I go to form of project 2 and how can I go back to previous form in C#??
Asked
Active
Viewed 1,442 times
-1
-
1You can't have two solutions in a project. – stuartd Feb 25 '15 at 17:10
-
When you change a value on one form have it put it into a database and then use that in the other form and vice versa – ZoomVirus Feb 25 '15 at 17:10
-
1i assumed you ment 2 projects in 1 solution – ZoomVirus Feb 25 '15 at 17:11
-
Yes yes 2 project in 1 solution – AMU Feb 25 '15 at 17:12
-
As long as you have project references between the 2 projects, you can expose public methods to do what you want. – Rufus L Feb 25 '15 at 17:13
-
and what is use of Add reference, i used to open that form from project 2, and if make both of it,it shows circular dependency error – AMU Feb 25 '15 at 17:19
1 Answers
0
Right click on project1 in Solution Explorer. Add -> Reference -> Solution -> [Choose project2 and mark it] -> OK
in project1 make something like this:
using project2; //or whatever namespace you have in project2
and then call it like that somewhere:
FormFromProject2.Show(); //FormFromProject2 is the name of the Form type you want to call
Voila!

Szer
- 3,426
- 3
- 16
- 36
-
i used to open that form from project 2, and if make both of it,it shows circular dependency error – AMU Feb 25 '15 at 17:23
-
If you referenced project1 in project2 then you used it somewhere for something. Could you show us what you tried to do? – Szer Feb 25 '15 at 17:29
-
I just nothing done yet because i already add reference project 1 in project 2,and i run it and open form 2 from form1 on button click , and there is a button to call form 2 from from 1,wat code want to give to that button of form2 – AMU Feb 25 '15 at 17:35
-
if those forms can call each other, why you divided them by different projects??? Just put them in one project and do Form.Show() – Szer Feb 25 '15 at 18:01
-
I think dependency can be resolved.both the peoject are from different parents. – AMU Feb 25 '15 at 18:26