1 : 修改DX 提示框中的英文字符
1 ///2 /// 重写DX弹出框 英文变为中文 3 /// 4 public class CHS : DevExpress.XtraEditors.Controls.Localizer 5 { 6 public override string GetLocalizedString(DevExpress.XtraEditors.Controls.StringId id) 7 { 8 switch (id) 9 {10 case DevExpress.XtraEditors.Controls.StringId.XtraMessageBoxYesButtonText:11 return "确定";12 case DevExpress.XtraEditors.Controls.StringId.XtraMessageBoxCancelButtonText:13 return "取消";14 case DevExpress.XtraEditors.Controls.StringId.XtraMessageBoxOkButtonText:15 return "是";16 case DevExpress.XtraEditors.Controls.StringId.XtraMessageBoxNoButtonText:17 return "否";18 }19 return base.GetLocalizedString(id);20 }21 }
如果想要修改其他的提示语可以在选择添加.
2 : 修改GridControl 中的 Find Clear 或其他的英文字符,替换为中文.
////// 用于处理DX控件中 控件名称 自定义 /// public class BuilderGridLocalizer : GridLocalizer { DictionaryCusLocalizedkeyValue = null; public BuilderGridLocalizer(Dictionary 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); } }
1 ///2 /// DX控件 自定义名称 3 /// 4 public static DictionarySetGridLocalizer(GridStringId[] grid, params string[] str) 5 { 6 Dictionary LocalizedKeyValue = new Dictionary (); 7 8 for (int i = 0; i < str.Count(); i++) 9 {10 LocalizedKeyValue.Add(grid[i], str[i]);11 }12 return LocalizedKeyValue;13 }
调用 :
1 public class BaseForm : RibbonForm 2 { 3 ///4 /// 将GridControl搜索按钮 英文变为中文 5 /// 6 public BaseForm() 7 { 8 GridStringId[] gridString = { GridStringId.FindControlFindButton, GridStringId.FindControlClearButton }; 9 string[] dxName = { "查找", "清空" };10 BuilderGridLocalizer builder = new BuilderGridLocalizer(DXControl.SetGridLocalizer(gridString, dxName));11 GridLocalizer.Active = builder; 12 }13 14 15 }