DevExpress GridView 自定义搜索按钮改为中文内容
首先将 GridControl 控件的搜索功能显示出来.
http://www.cnblogs.com/DeepLearing/p/3887601.html
显示效果如下:
可以通过 GridLocalizer 来实现更改 Find,Clear 的名称.
首先我们定义一个类,继承 GridLocalizer 并重写 GridLocalizedString 方法,1:避免重复 2 : 方便我们操作.代码如下
1 public class MyGridLocalizer : GridLocalizer 2 { 3 Dictionary<GridStringId, string> CusLocalizedKeyValue = null; 4 5 public MyGridLocalizer(Dictionary<GridStringId, string> cusLocalizedKeyValues) 6 { 7 this.CusLocalizedKeyValue = cusLocalizedKeyValues; 8 } 9 10 public override string GetLocalizedString(GridStringId id) 11 { 12 if(CusLocalizedKeyValue != null) 13 { 14 string gridStringDisplay = string.Empty; 15 foreach (var gridLocalizer in CusLocalizedKeyValue) 16 { 17 if (gridLocalizer.Key.Equals(id)) 18 { 19 gridStringDisplay = gridLocalizer.Value; 20 break; 21 } 22 } 23 24 return gridStringDisplay; 25 } 26 return base.GetLocalizedString(id); 27 } 28 29 }
然后再我们的后台添加一个方法用于修改Button内容..
1 public Dictionary<GridStringId,string> SetGridLocalizer() 2 { 3 Dictionary<GridStringId, string> LocalizedKeyValue = new Dictionary<GridStringId, string>(); 4 LocalizedKeyValue.Add(GridStringId.FindControlFindButton, "查找"); 5 LocalizedKeyValue.Add(GridStringId.FindControlClearButton, "清空"); 6 return LocalizedKeyValue; 7 }
最后调用处理一下就可以了.
1 private void Form1_Load(object sender, EventArgs e) 2 { 3 Dictionary<GridStringId, string> gridLocalizer = SetGridLocalizer(); 4 5 MyGridLocalizer Localizer = new MyGridLocalizer(gridLocalizer); 6 GridLocalizer.Active = Localizer; 7 8 gridControl1.DataSource = ""; 9 }
显示效果如下 :
作者:刘彬
出处:http://www.cnblogs.com/Albin/
如果您觉得阅读本文对您有帮助,请点一下“推荐”按钮,您的“推荐”将是我最大的写作动力!本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面