开发者

How to loop through the ChartColorPalette properties and add to list? [duplicate]

This question already has answers here: Closed 9 years ago.

Possible Duplicate:

How do I enumerate an enum?

I am using the Microsoft Chart Controls for .NET 3.5 (C#) and have a chart in a winform.

My hope is to allow the user to change the color palette based on their preference.

How do I iterate 开发者_开发知识库through the color properties of the ChartColorPalette and add them to a combobox list?

I know it should be something like:

for each(something in ChartColorPalette)
{
  combobox.items.add(something.ToString);
}


You can enumerate the names in your enum via the GetNames class method...

foreach(string s in Enum.GetNames(typeof(ChartColorPalette))
{
}

then later if you need the enum for the name you can parse the name value...

var val = (ChartColorPalette)Enum.Parse(typeof(ChartColorPalette),"theValue");


See how to enumerate an enum.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜