修改DevExpress中英文提示,将英文改为中文

1 : 修改DX 提示框中的英文字符

 /// <summary>
/// 重写DX弹出框 英文变为中文
/// </summary>
public class CHS : DevExpress.XtraEditors.Controls.Localizer
{
public override string GetLocalizedString(DevExpress.XtraEditors.Controls.StringId id)
{
switch (id)
{
case DevExpress.XtraEditors.Controls.StringId.XtraMessageBoxYesButtonText:
return "确定";
case DevExpress.XtraEditors.Controls.StringId.XtraMessageBoxCancelButtonText:
return "取消";
case DevExpress.XtraEditors.Controls.StringId.XtraMessageBoxOkButtonText:
return "是";
case DevExpress.XtraEditors.Controls.StringId.XtraMessageBoxNoButtonText:
return "否";
}
return base.GetLocalizedString(id);
}
}

如果想要修改其他的提示语可以在选择添加.

2 : 修改GridControl 中的 Find Clear 或其他的英文字符,替换为中文.

/// <summary>
/// 用于处理DX控件中 控件名称 自定义
/// </summary>
public class BuilderGridLocalizer : GridLocalizer
{
Dictionary<GridStringId, string> CusLocalizedkeyValue = null; public BuilderGridLocalizer(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);
} }
   /// <summary>
/// DX控件 自定义名称
/// </summary>
public static Dictionary<GridStringId, string> SetGridLocalizer(GridStringId[] grid, params string[] str)
{
Dictionary<GridStringId, string> LocalizedKeyValue = new Dictionary<GridStringId, string>(); for (int i = ; i < str.Count(); i++)
{
LocalizedKeyValue.Add(grid[i], str[i]);
}
return LocalizedKeyValue;
}

调用 :

   public class BaseForm : RibbonForm
{
/// <summary>
/// 将GridControl搜索按钮 英文变为中文
/// </summary>
public BaseForm()
{
GridStringId[] gridString = { GridStringId.FindControlFindButton, GridStringId.FindControlClearButton };
string[] dxName = { "查找", "清空" };
BuilderGridLocalizer builder = new BuilderGridLocalizer(DXControl.SetGridLocalizer(gridString, dxName));
GridLocalizer.Active = builder;
} }
上一篇:前端代码标准最佳实践:CSS


下一篇:hdu_5889_Barricade(最小割+最短路)