473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 5413
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
2
by: Markus Eßmayr | last post by:
Hello, I'm writing an extension class for the winforms button control using MC++. I created a class, derived from System::Windows::Forms::Button. In my class I want to extend the functionality...
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
2
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post by:
Hi, I am wondering why the .NET Framework is quite different from Win32 API when it comes to displaying system modal message boxes. Consider the four following types of system modal message...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.