直入主题吧!开发中往往需要将代码转换成中文显示在表格中。

如下图

下面就直接贴代码了.

C#代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data; namespace WpfApplication1
{
/// <summary>
/// Window4.xaml 的交互逻辑
/// </summary>
public partial class Window4 : Window
{ public static List<Areas> Data
{
get { return Areas.getgg(); }
} public Window4()
{
InitializeComponent();
gridcontrol.ItemsSource = NwindData.DataPerson;
} } public class NwindData
{ public static DataTable DataPerson
{
get { return setPerson(); }
} private static DataTable setPerson()
{
DataTable dt = new DataTable();
dt.Columns.Add("id",Type.GetType("System.Int32"));
dt.Columns.Add("username", Type.GetType("System.String"));
dt.Columns.Add("areaid", Type.GetType("System.Int32")); //这里的类型一定要和Area中的Areaid类型一致不然就显示不中文
DataRow row = dt.Rows.Add(); row[] = "";
row[] = "张三";
row[] = ""; row = dt.Rows.Add();
row[] = "";
row[] = "李四";
row[] = "";return dt;
} } public class Areas
{
int areaid; public int Areaid
{
get { return areaid; }
set { areaid = value; }
}
string areaName; public string AreaName
{
get { return areaName; }
set { areaName = value; }
}
public Areas(int areaid, string areaname)
{
this.areaid = areaid;
this.areaName = areaname;
} public static List<Areas> getgg()
{
List<Areas> list = new List<Areas>();
list.Add(new Areas(,"中国"));
list.Add(new Areas(,"美国"));
return list; }
}
}

XAML代码

<Window xmlns:my="clr-namespace:WpfApplication1"  x:Class="WpfApplication1.Window4"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dxdo="http://schemas.devexpress.com/winfx/2008/xaml/docking">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<dxg:GridControl Name="gridcontrol" >
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="id" MinWidth="100" Header="ID"/>
<dxg:GridColumn FieldName="username" MinWidth="100" Header="姓名"/>
<dxg:GridColumn FieldName="areaid" MinWidth="100" Header="地区ID"/>
<dxg:GridColumn FieldName="areaid"
EditSettings="{dxe:ComboBoxSettings DisplayMember=AreaName, ValueMember=Areaid, ItemsSource={x:Static my:Window4.Data}}" />
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView ShowGroupPanel="False" Name="ds" />
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
</Grid>
</Window>

到这里就ok了!

WPF Devexpress GridControl Value与Display转换的更多相关文章

  1. [Irving] Wpf DevexPress GridControl 获取选中行

    WPF前台绑定事件代码: <RelayAction TargetControl="{Binding ElementName=GCInstoragePart}" MethodN ...

  2. DevExpress GridControl使用(转)

    DevExpress GridControl使用 (一)原汁原味的表格展示 Dev控件中的表格控件GridControl控件非常强大.不过,一些细枝末节的地方有时候用起来不好找挺讨厌的.使用过程中,多 ...

  3. DevExpress GridControl使用方法

    一.如何解决单击记录整行选中的问题 View->OptionsBehavior->EditorShowMode 设置为:Click 二.如何新增一条记录 (1).gridView.AddN ...

  4. 实现DevExpress GridControl 只有鼠标双击后才进行修改数据

    1. 实现DevExpress GridControl 只有鼠标双击后才进行修改数据:修改GridView.OptionsBehavior.EditorShowMode属性为Click 2. 实现De ...

  5. DevExpress GridControl 使用方法技巧 总结 收录整理

    一.如何解决单击记录整行选中的问题 View->OptionsBehavior->EditorShowMode 设置为:Click 二.如何新增一条记录 ().gridView.AddNe ...

  6. Devexpress GridControl z

    http://minmin86121.blog.163.com/blog/static/4968115720144194923578/ 1 AllowNullInput=False; --Devexp ...

  7. DevExpress GridControl 单元格添加进度条(ProgressBar)

    首先可以使用DevExpress GridControl 自带的进度条控件. 但是我要用一个方法来设置所以的单元格进度,而不是每个单元格都要设置一遍,同时我想要根据进度值不同,进度条显示不同的颜色. ...

  8. DevExpress GridControl+UserControl实现分页

    志向不过是记忆的奴隶,生气勃勃地降生,但却很难成长. —— 莎士比亚 时隔一年,我写随笔真的很随意,想起了就来博客园写写,想不起来就任由懒惰支配着我.不过我到觉得这不是什么坏事,你不用为了完成某事而让 ...

  9. WPF Color、String、Brush转换

    原文:WPF Color.String.Brush转换 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/BYH371256/article/detai ...

随机推荐

  1. 【2018ICPC青岛】

    B 题意:给n个问题,每个问题有一个固定的答案ai(<=10^5).现在有m个约束关系,每个约束关系是一个二元组(ui,vi),表示你回答ui.vi问题的答案必须一样. 现在让你输出分别修复一个 ...

  2. P4248 [AHOI2013]差异 解题报告

    P4248 [AHOI2013]差异 题目描述 给定一个长度为 \(n\) 的字符串 \(S\),令 \(T_i\) 表示它从第 \(i\) 个字符开始的后缀.求 \[\displaystyle \s ...

  3. mysql:InnoDB行/表级锁实现/事务

    转载:http://book.51cto.com/art/200803/68127.htm 20.3.4 InnoDB行锁实现方式 InnoDB行锁是通过给索引上的索引项加锁来实现的,这一点MySQL ...

  4. 初识Unity Mesh

    Mesh概念:Mesh是Unity中的一个组件,称为网格组件.通俗的讲,Mesh是指模型的网格,3D模型是由多边形拼接而成,而多边形实际上是由多个三角形拼接而成的.所以一个3D模型的表面其实是由多个彼 ...

  5. LigerUI下拉选择列表LigerComboBox中tree的节点初始化默认选中的问题

    问题描述 用后台的Json传送tree的数据 前端用js方法来控制选中节点 此方法存在bug 实例: bug问题:无论设置的默认选中值是多少个,前台checkbox最多只显示选中一个,但是内容框中显示 ...

  6. Swarm使用原生的overlay网络

    一.Swarm Overlay Network Swarm有Service的概念.一个Service是指使用相同镜像.同时运行的多个容器,多个容器同时一起对外提供服务,多个容器之间负载均衡.每个Ser ...

  7. IDEA Mybatis plugin插件破解

    破解文件: 链接:https://pan.baidu.com/s/1J7asfLc5I0RBcoYX3_yNvQ 提取码:kjxv 使用方法: C:\Users\{你的用户名}\.IntelliJId ...

  8. 解决错误:Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

    在使用yum install的时候,偶尔会碰见这样的错误:Couldn’t open file /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 这是因为在你的 /etc/yum ...

  9. 51nod1019 逆序数

    1019 逆序数 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题  收藏  关注 在一个排列中,如果一对数的前后位置与大小顺序相反,即前面的数大于后面的数,那么它们就称为 ...

  10. java selenium常用API(WebElement、iFrame、select、alert、浏览器窗口、事件、js) 一

     WebElement相关方法 1.点击操作 WebElement button = driver.findElement(By.id("login")); button.clic ...