bobinorlando
asked on
Class Library - Why can't I inherit or import System.Windows.Forms. Form?
Why does this code show as an error in a Class Library?
Public Class Form1
Inherits System.Windows.Forms.Form
End Class
An Imports System.Windows.Forms.Form statement also shows as an error.
If I can't inherit or import this namespace, how can I instantiate form controls in my class?
What am I missing?
Public Class Form1
Inherits System.Windows.Forms.Form
End Class
An Imports System.Windows.Forms.Form statement also shows as an error.
If I can't inherit or import this namespace, how can I instantiate form controls in my class?
What am I missing?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It's a regular class and I actually named it something other than Form1, e.g. MyClass. However, I want to include a form in the class (if that is possible).
yes you need to add the references.
i think you are creating a classlibrary application type. in that case by default the forms reference is not included. if you want to use any of the forms, drawing capabilities you need to include respective references.
i think you are creating a classlibrary application type. in that case by default the forms reference is not included. if you want to use any of the forms, drawing capabilities you need to include respective references.
ASKER
Just so I understand, I notice that a windows application starts out with references to system.drawing but a class library project doesn't include that one, either.
So, if I want to work with form controls in classes I create, do I also have to add a reference to system.drawing and then import it?
All of which raises another quesiton I will post separately, what is the difference between importing, inheriting and references?