Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

Color Handling in NX: White is not member of Color

I ran this code directly in NX without any problem, however, when I put this code to Visual Studio, it returns errors "White is not member of Color" - any suggestion to fix this problem is appreciated.

 

 

2017-05-30_11-53-59.png

 

3 REPLIES

Re: Color Handling in NX: White is not member of Color

What namespace did you import to get the Color class? You probably need to add it as a reference in your VS project properties.

 

Solution
Solution
Accepted by topic author Secret
‎05-30-2017 06:56 PM

Re: Color Handling in NX: White is not member of Color

Do you have both 'Imports Snap' and 'Imports System.Drawing' in your program.

If I only have System.Drawing, then I can use this line:

Dim bckgrndColor As Color = Color.White

But if I have Snap also, then I have to fully qualify which Color I mean:

Dim bckgrndColor As System.Drawing.Color = Drawing.Color.White

because Snap.Color does not have a member named White.

Re: Color Handling in NX: White is not member of Color

You say the code works in the Journal Editor, but not in Visual Studio.

 

This is because code that's built/run in the Journal Editor automatically gets a reference to System.Drawing, so "Color" is understood to mean System.Drawing.Color.

 

In Visual Studio, you have to add the reference to System.Drawing yourself.

山田
yamada