DevExpress GridView 自定义搜索按钮改为中文内容

首先将 GridControl 控件的搜索功能显示出来.

http://www.cnblogs.com/DeepLearing/p/3887601.html

显示效果如下:

DevExpress GridView 自定义搜索按钮改为中文内容

可以通过 GridLocalizer 来实现更改 Find,Clear 的名称.

首先我们定义一个类,继承 GridLocalizer  并重写 GridLocalizedString 方法,1:避免重复 2 : 方便我们操作.代码如下

   public class MyGridLocalizer : GridLocalizer
{
Dictionary<GridStringId, string> CusLocalizedKeyValue = null; public MyGridLocalizer(Dictionary<GridStringId, string> cusLocalizedKeyValues)
{
this.CusLocalizedKeyValue = cusLocalizedKeyValues;
} public override string GetLocalizedString(GridStringId id)
{
if(CusLocalizedKeyValue != null)
{
string gridStringDisplay = string.Empty;
foreach (var gridLocalizer in CusLocalizedKeyValue)
{
if (gridLocalizer.Key.Equals(id))
{
gridStringDisplay = gridLocalizer.Value;
break;
}
} return gridStringDisplay;
}
return base.GetLocalizedString(id);
} }

然后再我们的后台添加一个方法用于修改Button内容..

  public Dictionary<GridStringId,string> SetGridLocalizer()
{
Dictionary<GridStringId, string> LocalizedKeyValue = new Dictionary<GridStringId, string>();
LocalizedKeyValue.Add(GridStringId.FindControlFindButton, "查找");
LocalizedKeyValue.Add(GridStringId.FindControlClearButton, "清空");
return LocalizedKeyValue;
}

最后调用处理一下就可以了.

   private void Form1_Load(object sender, EventArgs e)
{
Dictionary<GridStringId, string> gridLocalizer = SetGridLocalizer(); MyGridLocalizer Localizer = new MyGridLocalizer(gridLocalizer);
GridLocalizer.Active = Localizer; gridControl1.DataSource = "";
}

显示效果如下 :

DevExpress GridView 自定义搜索按钮改为中文内容

上一篇:关于fork()函数的作用


下一篇:.Net组件程序设计之序列化