I have a dll that has a class called Series. This class has a field which is an enumeration of DataTypes. I am binding the datagrid to a list of objects of this class, and I am able to display the enumeration values in a combobox fashion
However, the values’ names don’t make a lot of sense. For example, I want to display ‘prc’ as ‘price’ and still represent the correct object value.
this is what I currently do
this.seriesDataTypeColumn.Items.AddRange(new object[] {
MuDBLayer.DataType.mv,
MuDBLayer.DataType.vol,
MuDBLayer.DataType.num,
MuDBLayer.DataType.prc,
MuDBLayer.DataType.Composite});
mv, vol, num and prc are displayed in the datagridcomboboxes.
I wanna display
money value, volume, number, and price instead
any ideas?
Take a look at https://msmvps.com/blogs/deborahk/archive/2009/07/10/enum-binding-to-the-description-attribute.aspx or http://blogs.freshlogicstudios.com/Posts/View.aspx?Id=388f7d39-0b90-43bc-b03a-c1f605dfb499. You can add a Description attribute to your enums to display a more friendly value.
You might also find some more information in this related question How to bind a custom Enum description to a DataGrid.