在运行时列出颜色 [英] List Colors At Runtime

查看:109
本文介绍了在运行时列出颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在运行时为System.Drawing.Color列出颜色 - 我想在运行时给用户一个选项列表

系统。 Drawing.Color.AliceBlue(作为一种颜色的示例)。我可以

在数据库表中重新创建这个列表并从中拉出来,但是有一种方法

在代码中执行此操作以获取完整列表(用于一个组合,或者我想要b $ b想要)。以编程方式获取此列表一次将

放入表中甚至是有用的。很多选择要重新创建。


Derek

How would I list colors at runtime for System.Drawing.Color - I want to give
the user a list of choices at runtime, such as
System.Drawing.Color.AliceBlue (as an example of one color). I could
recreate this list in a database table and pull from it, but is there a way
to do this in code, to get a full list (for use in a combo, or however I
want to). It would even be useful to programmatically get this list once to
place it into a table. A lot of choices to recreate.

Derek

推荐答案

" Derek Hart" < de ******** @ yahoo.comwrote in message

news:eq ************** @ TK2MSFTNGP03.phx.gbl .. 。
"Derek Hart" <de********@yahoo.comwrote in message
news:eq**************@TK2MSFTNGP03.phx.gbl...

我如何在运行时为System.Drawing.Color列出颜色 - 我想

给用户一个选择列表运行时,例如

System.Drawing.Color.AliceBlue(作为一种颜色的示例)。我可以

在数据库表中重新创建这个列表并从中拉出来,但是在代码中有一个

方法来获取完整列表(用于一个组合,或者我想要的b $ b。以编程方式获取此列表

一次将其放入表中甚至是有用的。有很多选择要重新创建。
How would I list colors at runtime for System.Drawing.Color - I want to
give the user a list of choices at runtime, such as
System.Drawing.Color.AliceBlue (as an example of one color). I could
recreate this list in a database table and pull from it, but is there a
way to do this in code, to get a full list (for use in a combo, or however
I want to). It would even be useful to programmatically get this list
once to place it into a table. A lot of choices to recreate.



您需要将其转换为VB:

foreach(Enum.GetValues中的KnownColor col(typeof(KnownColor))) />
{

颜色= Color.FromKnownColor(col);

if(!color.IsSystemColor)

{

Console.WriteLine(col.ToString());

}

}

You will need to translate this to VB:
foreach(KnownColor col in Enum.GetValues(typeof(KnownColor)))
{
Color color = Color.FromKnownColor(col);
if(!color.IsSystemColor)
{
Console.WriteLine(col.ToString());
}
}


Derek,


所有颜色都是ARGB,即从0000到FFFF。很多颜色你可以

看到(正好是32位)


你可以用color.fromArgb获得所有


因此你的意思是什么颜色?


Cor

Derek,

All colors are ARGB, that is from 0000 to FFFF. A lot of colors as you can
see (exactly 32bit)

Which you can get all with color.fromArgb

Therefore what colors do you mean?

Cor


1月17日凌晨3:10 ,Derek Hart < derekmh ... @ yahoo.comwrote:
On Jan 17, 3:10 am, "Derek Hart" <derekmh...@yahoo.comwrote:

我如何在运行时为System.Drawing.Color列出颜色 - 我想给予

用户在运行时的选择列表,例如

System.Drawing.Color.AliceBlue(作为一种颜色的示例)。我可以

在数据库表中重新创建这个列表并从中拉出来,但是有一种方法

在代码中执行此操作以获取完整列表(用于一个组合,或者我想要b $ b想要)。以编程方式获取此列表一次将

放入表中甚至是有用的。有很多选择要重新创建。


Derek
How would I list colors at runtime for System.Drawing.Color - I want to give
the user a list of choices at runtime, such as
System.Drawing.Color.AliceBlue (as an example of one color). I could
recreate this list in a database table and pull from it, but is there a way
to do this in code, to get a full list (for use in a combo, or however I
want to). It would even be useful to programmatically get this list once to
place it into a table. A lot of choices to recreate.

Derek



ColorDialog控制?或者system.drawing.color提供了

颜色的列表。


如果你的问题是列出并呈现给用户,

最简单的方法是在我看来使用colordialog。


如果ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK那么

''关联颜色与您的对象

''示例:me.backcolor = colordialog1.color

结束如果

ColorDialog control? or system.drawing.color provides the list of
colors.

If your problem is listing and presenting them to the user, the
shortest way is to use colordialog in my opinion.

If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
''Associate the color with your object
''Example: me.backcolor = colordialog1.color
End If


这篇关于在运行时列出颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆