Link to home
Start Free TrialLog in
Avatar of bobinorlando
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?



ASKER CERTIFIED SOLUTION
Avatar of appari
appari
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bobinorlando
bobinorlando

ASKER

No I didn't. It does seem to solve the problem.

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?
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.