473,785 Members | 2,669 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3531
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.FromKnown Color(KnownColo r.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************* ********@z14g20 00...legro ups.com...
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.FromKnown Color?

KnownColor ColorNum = KnownColor.Blue ;
Pen pen = new Pen(Color.FromK nownColor(Color Num));

Hope this helps
Jay

"Jim McGivney - Office" <jm*******@nosp am.sbcglobal.ne t> wrote in message
news:OI******** ******@tk2msftn gp13.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
6211
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 report an error of "more pseudo attributes expected" if it is:
3
25562
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? Thanks
31
5725
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 calendar, 7 across by whatever needed down, and I manually create it each month - not a big deal. Every day I go in and darken the background color of the current day's cell by changing the appropriate <TD> entry to <TD bgcolor="c63800"> and...
8
25078
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 different table. While I am using the tools in Access for query setup, its easier to show it on here using the SQL for the query, which is as follows( the table is ): DELETE .date, .,
1
1349
by: Tom | last post by:
is it possible to specify a custom color code say #6E92GD for bg in winform ? Thanks Tom
16
12079
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 numbers using asp.net? I know about the random namespace within .net, but I need a reference to some code that do the similar stated function above. Plus If you have any coding practice ideas for the above defined project please share them.
6
2613
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 3.21 will display 3.21
4
1708
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
4229
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 way to increment from one color to the next - but I have no idea what it is. Does anyone know how to do this? Any suggestions greatly appreciated!! Thanks!
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10324
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9949
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.