473,386 Members | 1,817 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,386 software developers and data experts.

Getting Named Color Names and values????

How can I get value pairs of named colors and the color they represent?

I want to easily get these colornames and then their associated color values
into a file so I can add to the list and offer this list in an owner drawn
listbox for the user to choose colors.

thanks,

Shane
Nov 20 '05 #1
8 7371
Nevermind, I found out how to get these.

Below is a sample for anyone else who reads this and might not know..

there may be a better way but this will get the info in a file for me and
that is all I care about... and there may be more than 165 known colors but
I don't think so.
Dim c As Color
For i As Byte = 0 To 165
c = Color.FromKnownColor(i)
Debug.WriteLine(String.Format("{0} : {1},{2},{3}",
c.ToKnownColor.ToString(), c.R, c.G, c.B))
Next


"SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:u%****************@TK2MSFTNGP12.phx.gbl...
How can I get value pairs of named colors and the color they represent?

I want to easily get these colornames and then their associated color values into a file so I can add to the list and offer this list in an owner drawn
listbox for the user to choose colors.

thanks,

Shane

Nov 20 '05 #2
* "SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> scripsit:
How can I get value pairs of named colors and the color they represent?

I want to easily get these colornames and then their associated color values
into a file so I can add to the list and offer this list in an owner drawn
listbox for the user to choose colors.


\\\
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ListBox1.DataSource = [Enum].GetNames(GetType(KnownColor))
End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Me.ListBox1.BackColor = Color.FromKnownColor(DirectCast([Enum].Parse(GetType(KnownColor), CStr(ListBox1.SelectedItem)), KnownColor))
End Sub
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Wow that is an awesome solution. I will have to try it.
I choose to write all of those to an XML file so that the user can add
his/her own colors to the list.

Shane

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2j*************@uni-berlin.de...
* "SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> scripsit:
How can I get value pairs of named colors and the color they represent?

I want to easily get these colornames and then their associated color values into a file so I can add to the list and offer this list in an owner drawn listbox for the user to choose colors.
\\\
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles MyBase.Load Me.ListBox1.DataSource = [Enum].GetNames(GetType(KnownColor))
End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged Me.ListBox1.BackColor = Color.FromKnownColor(DirectCast([Enum].Parse(GetType(KnownColor),
CStr(ListBox1.SelectedItem)), KnownColor)) End Sub
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #4
Could you tell me what this [Enum] is exactly?
What object does it belong to? Object?

I assume it is hidden?

Thanks,

Shane
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2j*************@uni-berlin.de...
* "SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> scripsit:
How can I get value pairs of named colors and the color they represent?

I want to easily get these colornames and then their associated color values into a file so I can add to the list and offer this list in an owner drawn listbox for the user to choose colors.
\\\
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles MyBase.Load Me.ListBox1.DataSource = [Enum].GetNames(GetType(KnownColor))
End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged Me.ListBox1.BackColor = Color.FromKnownColor(DirectCast([Enum].Parse(GetType(KnownColor),
CStr(ListBox1.SelectedItem)), KnownColor)) End Sub
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #5
* "SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> scripsit:
Could you tell me what this [Enum] is exactly?
What object does it belong to? Object?
It's the 'Enum' class. 'Enum' is a keyword in VB.NET, so we have to
"escape" it with the square brackets.
I assume it is hidden?


No, it isn't ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6
Cool! This is one of the greatest things I've learned lately. Will be
helpful in many ways.

Danke sehr gut,

Herfried

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2j*************@uni-berlin.de...
* "SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> scripsit:
Could you tell me what this [Enum] is exactly?
What object does it belong to? Object?


It's the 'Enum' class. 'Enum' is a keyword in VB.NET, so we have to
"escape" it with the square brackets.
I assume it is hidden?


No, it isn't ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #7
"SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> schrieb
Could you tell me what this [Enum] is exactly?
What object does it belong to? Object?

I assume it is hidden?


No, it's not hidden. It's a type in the System namespace in mscorlib.dll
(see object browser). The square brackets are there to distinguish between
the type and the VB.Net Enum keyword, like in

enum MyEnum
a
b
end enum
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #8
* "SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> scripsit:
Cool! This is one of the greatest things I've learned lately. Will be
helpful in many ways.
The square brackets are documented here:

<URL:http://msdn.microsoft.com/library/en-us/vbls7/html/vblrfVBSpec2_2.asp>
Danke sehr gut,


:-)

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #9

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

Similar topics

66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
3
by: Varad | last post by:
Hi all Pls give me some insight as to what I should be doing. I have a form where I have 20 text boxes and when an user submits the form I save it to a database. When they want to retrieve it, I...
15
by: Aaron Gray | last post by:
<iframe name="iframe" width="100%" height="25%" src="test1.txt"> </iframe> <a href="test1.txt" target="input">one</a> <a href="test2.txt" target="input">two</a> <form name="form1"> <textarea...
48
by: Adam Ruth | last post by:
Hello, Has there ever been any talk to adding named parameters to C? I enjoy using them in my Python and Ada code and can see their usefulness in C. I can envision an implementation where the...
5
by: Booted Cat | last post by:
I've seen lots of discussions on the proposed inclusion of "function call with named arguments" to C/C++ on these newsgroups. My proposal is slightly different in that: * No ANSI approval is...
7
by: Aaron Gray | last post by:
I put together the following code to get the href's parameters :- function GetParameters() { var arg = new Object(); var href = document.location.href; if ( href.indexOf( "?") != -1) { var...
41
by: Jim | last post by:
Hi guys, I have an object which represents an "item" in a CMS "component" where an "item" in the most basic form just a field, and a "component" is effectively a table. "item" objects can be...
0
by: rogerford | last post by:
1) I have a Namedrange which is named Company in sheet 2. Sheet 1 cell A2 has a list created via data validation referencing to this sheet 2 Column A values. 2) If i go to Name Manager (by doing a...
3
by: koti688 | last post by:
how to get the column names and the values of them in select statment. I have a packaze like this named ADB.pm package ADB; use DBI; @ISA = ('Exporter');
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.