当前位置: 代码迷 >> .NET报表 >> wpf datagrid Converter解决方案
  详细解决方案

wpf datagrid Converter解决方案

热度:2089   发布时间:2013-02-25 00:00:00.0
wpf datagrid Converter
数据库存的是0,1,2,3之类的。界面显示时如何变成具体的值了 如:经销,营销之类的。要是显示0,1,2,3之类客户是看不懂的。有办法在datagrid里将数字转换为对应的值吗

------解决方案--------------------------------------------------------
现在c#文件中写一个转换类,把数字转成枚举名称(或字符串),比如:
C# code
// Window1.xaml.csnamespace WpfApplication1{    public class DataConverter : IValueConverter    {        enum EnumValues { 经销 = 1, 营销 = 2, 生产 = 3 }        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)        {            return (EnumValues)value;        }        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)        {            throw new NotImplementedException();        }    }}
  相关解决方案