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

display all colors

Is there a programatic way to iterate through all the named colors?
Something like:

HtmlTable ht = new HtmlTable();
HtmlTableRow htr;
HtmlTableCell htc;
foreach (Color c in [collection of all colors]) //I CAN'T FIND COLLECTION OF
ALL COLORS
{
htr = new HtmlTableRow();
htc = new HtmlTableCell();
htc.InnerText = c.Name;
htr.Cells.Add(htc);
ht.Rows.Add(htr);
}
phColors.Controls.Add(ht); //Display table in a placeholder control

Thanks in advance!
Mark
Nov 18 '05 #1
6 2218
collection of colors from where?
Server? These would be irrelevant since they are interpreted by the client.
Client? nope....can't get em, besides, named colors can be "adjusted" I
believe. Get the #00000 values. Probably easier to just build a list of
standards though.

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message
news:Ox**************@TK2MSFTNGP12.phx.gbl...
Is there a programatic way to iterate through all the named colors?
Something like:

HtmlTable ht = new HtmlTable();
HtmlTableRow htr;
HtmlTableCell htc;
foreach (Color c in [collection of all colors]) //I CAN'T FIND COLLECTION OF ALL COLORS
{
htr = new HtmlTableRow();
htc = new HtmlTableCell();
htc.InnerText = c.Name;
htr.Cells.Add(htc);
ht.Rows.Add(htr);
}
phColors.Controls.Add(ht); //Display table in a placeholder control

Thanks in advance!
Mark

Nov 18 '05 #2
Here's some code I use that might give you a hand:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
If Not IsPostBack Then
Dim strSelectedColor As String
Dim li As New ListItem
Dim enumColor As New KnownColor
Dim Colors As Array = _
[Enum].GetValues(enumColor.GetType())
DropDownList1.DataSource = Colors
DropDownList1.DataBind()
strSelectedColor = DropDownList1.Items(0).Text
li.Value = 0
li.Text = "--ALL"
DropDownList1.Items.Insert(0, li)
End If
End Sub 'Page_Load
Private Sub DropDownList1_SelectedIndexChanged _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles DropDownList1.SelectedIndexChanged
Label1.Text = DropDownList1.SelectedItem.Text
End Sub

Ken
Microsoft MVP [ASP.NET]
"Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message
news:Ox**************@TK2MSFTNGP12.phx.gbl...
Is there a programatic way to iterate through all the named colors?
Something like:

HtmlTable ht = new HtmlTable();
HtmlTableRow htr;
HtmlTableCell htc;
foreach (Color c in [collection of all colors]) //I CAN'T FIND COLLECTION
OF
ALL COLORS
{
htr = new HtmlTableRow();
htc = new HtmlTableCell();
htc.InnerText = c.Name;
htr.Cells.Add(htc);
ht.Rows.Add(htr);
}
phColors.Controls.Add(ht); //Display table in a placeholder control

Thanks in advance!
Mark


Nov 18 '05 #3
System.Drawing.Color has them all

"Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message news:Ox**************@TK2MSFTNGP12.phx.gbl...
Is there a programatic way to iterate through all the named colors?
Something like:

HtmlTable ht = new HtmlTable();
HtmlTableRow htr;
HtmlTableCell htc;
foreach (Color c in [collection of all colors]) //I CAN'T FIND COLLECTION OF
ALL COLORS
{
htr = new HtmlTableRow();
htc = new HtmlTableCell();
htc.InnerText = c.Name;
htr.Cells.Add(htc);
ht.Rows.Add(htr);
}
phColors.Controls.Add(ht); //Display table in a placeholder control

Thanks in advance!
Mark

Nov 18 '05 #4
Good points. However, let's assume that I had the same client on every
desktop, which means the colors would render the same. We're not shooting
for perfection - just a display of the available colors and their names
and/or numbers. What's the best method of iterating through the "typical"
available colors?

Thanks again.

Mark

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:uT**************@TK2MSFTNGP09.phx.gbl...
collection of colors from where?
Server? These would be irrelevant since they are interpreted by the client. Client? nope....can't get em, besides, named colors can be "adjusted" I
believe. Get the #00000 values. Probably easier to just build a list of
standards though.

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message
news:Ox**************@TK2MSFTNGP12.phx.gbl...
Is there a programatic way to iterate through all the named colors?
Something like:

HtmlTable ht = new HtmlTable();
HtmlTableRow htr;
HtmlTableCell htc;
foreach (Color c in [collection of all colors]) //I CAN'T FIND
COLLECTION OF
ALL COLORS
{
htr = new HtmlTableRow();
htc = new HtmlTableCell();
htc.InnerText = c.Name;
htr.Cells.Add(htc);
ht.Rows.Add(htr);
}
phColors.Controls.Add(ht); //Display table in a placeholder control

Thanks in advance!
Mark


Nov 18 '05 #5
Thanks!! This worked well. I ended up using the following code to create
an HtmlTable instance and add it to a placeholder control on my page:

HtmlTable ht = new HtmlTable();
HtmlTableRow htr;
HtmlTableCell htc;

KnownColor enumColor = new KnownColor();
Array colors = Enum.GetValues(enumColor.GetType());

bool bFirstColorFound = false;
for (int i = 0; i < colors.Length; i++)
{
string strColor = colors.GetValue(i).ToString();
if ( strColor == "AliceBlue")
{
bFirstColorFound = true;
}
if (bFirstColorFound == true)
{
htr = new HtmlTableRow();

//FIRST CELL
htc = new HtmlTableCell();
htc.InnerText = strColor ;
htr.Cells.Add(htc);

//SECOND CELL
htc = new HtmlTableCell();
htc.BgColor = strColor;
htc.InnerHtml = @"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
htr.Cells.Add(htc);

//Add row to table.
ht.Rows.Add(htr);
}
}

phColors.Controls.Add(ht);


"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:en****************@TK2MSFTNGP12.phx.gbl...
Here's some code I use that might give you a hand:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
If Not IsPostBack Then
Dim strSelectedColor As String
Dim li As New ListItem
Dim enumColor As New KnownColor
Dim Colors As Array = _
[Enum].GetValues(enumColor.GetType())
DropDownList1.DataSource = Colors
DropDownList1.DataBind()
strSelectedColor = DropDownList1.Items(0).Text
li.Value = 0
li.Text = "--ALL"
DropDownList1.Items.Insert(0, li)
End If
End Sub 'Page_Load
Private Sub DropDownList1_SelectedIndexChanged _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles DropDownList1.SelectedIndexChanged
Label1.Text = DropDownList1.SelectedItem.Text
End Sub

Ken
Microsoft MVP [ASP.NET]
"Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message
news:Ox**************@TK2MSFTNGP12.phx.gbl...
Is there a programatic way to iterate through all the named colors?
Something like:

HtmlTable ht = new HtmlTable();
HtmlTableRow htr;
HtmlTableCell htc;
foreach (Color c in [collection of all colors]) //I CAN'T FIND COLLECTION OF
ALL COLORS
{
htr = new HtmlTableRow();
htc = new HtmlTableCell();
htc.InnerText = c.Name;
htr.Cells.Add(htc);
ht.Rows.Add(htr);
}
phColors.Controls.Add(ht); //Display table in a placeholder control

Thanks in advance!
Mark

Nov 18 '05 #6
And thanks for the C# conversion!

"Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message
news:uf**************@TK2MSFTNGP10.phx.gbl...
Thanks!! This worked well. I ended up using the following code to create
an HtmlTable instance and add it to a placeholder control on my page:

HtmlTable ht = new HtmlTable();
HtmlTableRow htr;
HtmlTableCell htc;

KnownColor enumColor = new KnownColor();
Array colors = Enum.GetValues(enumColor.GetType());

bool bFirstColorFound = false;
for (int i = 0; i < colors.Length; i++)
{
string strColor = colors.GetValue(i).ToString();
if ( strColor == "AliceBlue")
{
bFirstColorFound = true;
}
if (bFirstColorFound == true)
{
htr = new HtmlTableRow();

//FIRST CELL
htc = new HtmlTableCell();
htc.InnerText = strColor ;
htr.Cells.Add(htc);

//SECOND CELL
htc = new HtmlTableCell();
htc.BgColor = strColor;
htc.InnerHtml = @"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
htr.Cells.Add(htc);

//Add row to table.
ht.Rows.Add(htr);
}
}

phColors.Controls.Add(ht);


Nov 18 '05 #7

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

Similar topics

1
by: RootShell | last post by:
Hello How can i use the GD Library to only show the White (or the hex value of white) pixels of a image? Imagine i have a 8 color picture in PNG format. This is to use on a color puzzle...
2
by: scott | last post by:
In a regular drop down form element like below, is there a way to display associated colors with each option? Basically, I'd like it to look like Outlook's Label Control drop down that displays a...
10
by: wideopensvt | last post by:
I'm having a display issue with Javascript pages on a new computer. Background colors don't appear within tables or frames in Internet Explorer 6. Example #1:...
6
by: Mark | last post by:
Is there a programatic way to iterate through all the named colors? Something like: HtmlTable ht = new HtmlTable(); HtmlTableRow htr; HtmlTableCell htc; foreach (Color c in ) //I CAN'T FIND...
10
by: Sarah Smith | last post by:
Hello, I am a bit of a newbie to VB.NET, but not totally new. I took the plunge recently and decided (along with my colleagues), to try to convert/port a VB6 client/server app to .Net. (I'm...
4
by: NewAlias | last post by:
How to display comments for each enum entry? 'Enum example with commnents commented Private Enum MyEnum YourName =1 ' Set this to get your real name YourAge=2 ' Set this to get your real age...
25
by: Dave | last post by:
Hello. In trying to get an anchor element to stylistically match an input or button element, I find that the button and input cannot be styled according to the 2.1 CSS spec. For example, I...
1
by: flit | last post by:
Hi all, How Can I do in the simplest way, display in html one table with the return of 3 collums? Like 1- consult mysql base 2- make the select query 3- show the values. I am a kind of...
12
by: active | last post by:
I've been looking on the Internet for a way to convert a DIB to a Bitmap without success. Now I'm wondering if that is the approach I should be taking. All I want to do is display the DIB or...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.