在运行时列出颜色

在运行时列出颜色

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

问题描述

我如何在运行时为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

推荐答案



您需要将其转换为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());
}
}





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


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

08-21 13:29