How do I call a Form in a different project but in the same solution???

A

Aaron Ackerman

I have a form that I need to call that is in it's own project in the SAME
solution and I am at a loss.
So what I am trying to do is call Form1 in Project 1 from Form2 in Project2.

How do I do this??? I can't see it?
 
A

Armin Zingler

Aaron Ackerman said:
I have a form that I need to call that is in it's own project in the
SAME solution and I am at a loss.
So what I am trying to do is call Form1 in Project 1 from Form2 in
Project2.

How do I do this??? I can't see it?

In the solution explorer, right-click on "references", select "add". In the
opened dialog, open tab "projects". There you can set the reference to the
class libraries in the same solution.


BTW, please post only to the appropriate groups!
 
A

Azhagan

Though you have your two projects under one solution, how are they
related? You cannot relate (add a reference) from one exe to another exe.
I assume one of the projects (Project2) is a DLL in which case, you can call
the form from second project by creating an instance of it. Like so,

Project2.Form2 objForm = new Project2.Form2(); // assuming
Project2 is the default namespace for Project2.
objForm.Show();

Having a userinterface in DLLs is not recommended since if you are
hosting them under COM+, they might pop this screen up. A better approach
would be to log those messages to your own logging mechanism or to windows
event log.

Hope this helps.
-Azhagan.
 
H

Herfried K. Wagner [MVP]

* "Aaron Ackerman said:
I have a form that I need to call that is in it's own project in the SAME
solution and I am at a loss.
So what I am trying to do is call Form1 in Project 1 from Form2 in Project2.

The type of the other project must not be an Executable project (use a
class library instead). Then you can reference this project (have a
look at the other project's context menu in the solution explorer) and
use the classes.
 
C

Charlie Smith

Create a namespace for your solution and place all projects within it.
(remember, you can only reference objects that exist)
 
T

Tony Dong

Aaron Ackerman said:
I have a form that I need to call that is in it's own project in the SAME
solution and I am at a loss.
So what I am trying to do is call Form1 in Project 1 from Form2 in Project2.

How do I do this??? I can't see it?

Go to property for Project2, and set up output type to class libary, make a
reference from project1, and then your will see it will be works.

Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top