Instantiate a form from another project

J

jack

Hello,

I have a set of class library projects that are used by a Windows
application project. I would like to add forms that are specfic to those
class library projects and instantiate them from the windows application
project. Of course I can't add forms to my class library projects, however,
I'm apprehensive about changing those projects to windows application
projects.

Can anyone advise me on the various alternatives to accomplish what I'm
trying to do and what I lose/gain by changing my class library projects to
Windows application projects?

Thanks in advance!
Jack
 
H

Herfried K. Wagner [MVP]

jack said:
I have a set of class library projects that are used by a Windows
application project. I would like to add forms that are specfic to those
class library projects and instantiate them from the windows application
project. Of course I can't add forms to my class library projects,
however, I'm apprehensive about changing those projects to windows
application projects.

You can actually define form types in your class library. Then simply
reference the class library from your Windows Forms application (Windows
Forms applications cannot be referenced!), import the class library's
namespace and instantiate the forms defined in the class library.
 

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