Display enum in ComboBox with spaces

后端 未结 7 1059
北海茫月
北海茫月 2020-12-31 06:03

I have an enum, example:

enum MyEnum
{
My_Value_1,
My_Value_2
}

With :

comboBox1.DataSource = Enum.GetValues(typeof(MyEnum)         


        
相关标签:
7条回答
  • 2020-12-31 07:04

    I think that this is not very good idea to map internal enum name into user space. What if you refactor your enum value? So I suggest you to take a look at this article (Localizing .NET Enums). Using technique described in this article, you can not only replace '_' with spaces, but also make different enum representation for different languages (using resources).

    0 讨论(0)
提交回复
热议问题