473,406 Members | 2,371 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,406 software developers and data experts.

Specify number get color

Is there a way to specify a number (0-141) to obtain one of the system
colors ?
Pen pen = new Pen(ColorNum);
where ColorNum is a method to specify a color by its enumeration value.
Thanks,
Jim
Nov 17 '05 #1
3 3516
Have you considered using the Pens class and using a predesigned pen?
There are pens defined already for the system colors. For example:
Pens.Blue

Otherwise, you can select the color by name:

Pen pen = new Pen(Color.Blue)

Be sure to dispose of your pens when you are done using them.

Nov 17 '05 #2
I think Jim wanted a system color, like ButtonFace, ActiveCaption...In the
framework, these colors are called KnownColor and can be obtained like this
:

Color c = Color.FromKnownColor(KnownColor.ButtonFace)

which can then be used in the Pen constructor.

BTW, why do you need to dispose the pens ? It's managed. The Pen destructor
releases its resources.

Fabien
"Chris Dunaway" <du******@gmail.com> a écrit dans le message de news:
11*********************@z14g2000cwz.googlegroups.c om...
Have you considered using the Pens class and using a predesigned pen?
There are pens defined already for the system colors. For example:
Pens.Blue

Otherwise, you can select the color by name:

Pen pen = new Pen(Color.Blue)

Be sure to dispose of your pens when you are done using them.

Nov 17 '05 #3
Jim,
In addition to the other comments:

Have you tried Color.FromKnownColor?

KnownColor ColorNum = KnownColor.Blue;
Pen pen = new Pen(Color.FromKnownColor(ColorNum));

Hope this helps
Jay

"Jim McGivney - Office" <jm*******@nospam.sbcglobal.net> wrote in message
news:OI**************@tk2msftngp13.phx.gbl...
| Is there a way to specify a number (0-141) to obtain one of the system
| colors ?
| Pen pen = new Pen(ColorNum);
| where ColorNum is a method to specify a color by its enumeration value.
| Thanks,
| Jim
|
|
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kent Tong | last post by:
Hi, Why is it required to specify the encoding pseudo attribute in a DTD? For example, it is OK to have: <?xml version="1.0" encoding="ISO-8859-1"?> <!ELEMENT ...> But it causes Xerces to...
3
by: chirs | last post by:
Hi, I'd like to use a var to hold a Hex number. But in this code: var a = "ffff00" a is a string. var a=ffff00 will not work either. How can I put a Hex number ffff00 into a var? ...
31
by: Arthur Shapiro | last post by:
I'm the webmaster for a recreational organization. As part of one page of the site, I have an HTML "Calendar at a Glance" of the organization's events for the month. It's a simple table of a...
8
by: John Baker | last post by:
Hi: Access 2000 W98! I have a table with numerous records in it, and am attempting to delete certain records that have been selected from it. These are selected based on the ID number in a...
1
by: Tom | last post by:
is it possible to specify a custom color code say #6E92GD for bg in winform ? Thanks Tom
16
by: Leon | last post by:
I need a program that generate 5 non-duplicates random number between 1-10 as string values store in an array. Do anybody know of any good books or websites that explain how to generator random...
6
by: Donal McWeeney | last post by:
Hi, Is there a way to specify on the predefined format strings like P and N that you want displayed all the decimals in the number... for example 3 will display 3 2.1 will display 2.1...
4
by: Richard | last post by:
When i try sorting in the database, it sorts the numbers: 0 1 102 2 304 305 4 etc....
5
by: simchajoy2000 | last post by:
Hi, I need to calculate a range of colors given the beginning and ending colors in hex values (i.e. blue to red). I know there is a logic to hex numbers and there is probably a fairly simple...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.