System.Drawing.Color in a public class?

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I'm a bit baffled. I'm fairly new to VB.NET so maybe I'm missing
something. I'm creating a class that has some application-specific
methods and properties and one thing I'd like to do is define some
properties specific to form colors. So what I want to do is define my
class like

Imports System.Windows.Forms
Imports System.Drawing.Color
Public Class Forms
... my stuff here...
End Class

However, when I include "Imports System.Drawing.Color" I get an error
"Namespace or type 'Color' for the Imports 'System.Drawing.Color'
cannot be found.". In fact after typing "System.Drawing." the only
option in IntelliSence is "Design".

Is there some reason that I cannot import System.Drawing.Color into my
class? This is just a regular class, not one associated with a form,
usercontrol, etc.
 
You should import the namespace containing the class you want, not the class
itself (I am not sure what that would even mean).

If you import System.Drawing, you can then just use Color anywhere you need
it in your class.
 
Negative... tried that. If I import "System.Drawing" and try to
reference "System.Drawing.Color" in the class, I get the error "Type
'System.Drawing.color' is not defined.".
 
First off, the whole point of importing a namespace is so that you can just
say something like:

Dim c as Color

If you had to say

Dim c as System.Drawing.Color

Then what would be the point of doing the imports statement?

It sounds like you are missing a reference to System.Drawing.dll. Namespaces
can be across different DLL's, and it sounds like you are missing the one
where Color is.
 
Back
Top