如何将enum中的值作为combobox选项?

shishn 2005-07-02 12:11:52
想实现多选一.
...全文
293 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
俞庆平 2005-07-02
  • 打赏
  • 举报
回复
string [] names = Enum.GetNames(typeof(DockStyle));
comboBox1.Items.Clear();
foreach(string name in names)
{
this.comboBox1.Items.Add(name);
}
俞庆平 2005-07-02
  • 打赏
  • 举报
回复
using System;

public class GetNamesTest {
enum Colors { Red, Green, Blue, Yellow };
enum Styles { Plaid, Striped, Tartan, Corduroy };

public static void Main() {

Console.WriteLine("The values of the Colors Enum are:");
foreach(string s in Enum.GetNames(typeof(Colors)))
Console.WriteLine(s);

Console.WriteLine();

Console.WriteLine("The values of the Styles Enum are:");
foreach(string s in Enum.GetNames(typeof(Styles)))
Console.WriteLine(s);
}
}

110,570

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧