在DataGridComboBox问题中显示枚举值 [英] displaying enumeration values in a DataGridComboBox problem
问题描述
我有一个dll,有一个类叫Series。这个类有一个字段,它是DataTypes的枚举。我将datagrid绑定到这个类的对象列表,并且我能够以组合框方式显示枚举值
然而,值的名称没有什么意义。例如,我想将'prc'显示为'price',并仍然表示正确的对象值。
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.seriesDataTypeColumn.Items.AddRange(new object[] {
MuDBLayer.DataType.mv,
MuDBLayer.DataType.vol,
MuDBLayer.DataType.num,
MuDBLayer.DataType.prc,
MuDBLayer.DataType.Composite});
mv,vol,num和prc显示在datagridcombobox中。
我想显示
货币值,音量,数量和价格,而不是
任何想法?
mv, vol, num and prc are displayed in the datagridcomboboxes. I wanna display money value, volume, number, and price instead any ideas?
推荐答案
查看 https://msmvps.com/blogs/deborahk/archive/2009/07/10/enum-binding-to-the-description-attribute.aspx 或 http://blogs.freshlogicstudios.com/Posts/View.aspx?Id=388f7d39 -0b90-43bc-b03a-c1f605dfb499 。
您还可以在此相关问题中找到更多信息如何将自定义Enum描述绑定到DataGrid 。
You might also find some more information in this related question How to bind a custom Enum description to a DataGrid.
这篇关于在DataGridComboBox问题中显示枚举值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!