472,792 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,792 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 5322
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.