469,609 Members | 1,209 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

System.Drawing.Color in a public class?

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.

Nov 28 '05 #1
4 4886
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.

"Steve" <st*********@eglin.af.mil> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
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.

Nov 28 '05 #2
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.".

Nov 28 '05 #3
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.

"Steve" <st*********@eglin.af.mil> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
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.".

Nov 28 '05 #4
Bingo! I knew it had to be something very obvious that I was missing.
Many thanks...

Nov 28 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Terrence | last post: by
3 posts views Thread by Terrence | last post: by
2 posts views Thread by Markus Eßmayr | last post: by
2 posts views Thread by =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.