项目使用的界面库是DevExpress
相当好用,不过里面弹出对话框XtraMessageBox的按钮都是英文的,
可能会对用户造成困扰,
网上搜了搜,找到一种比较简单的方法解决这个问题,如下:
首先:定义一个继承自Localizer的类
using DevExpress.XtraEditors.Controls;
namespace Com.SuyPower.Pgis.Main
{
class LocalizationCHS:DevExpress.XtraEditors.Controls.Localizer
{
public override string GetLocalizedString(DevExpress.XtraEditors.Controls.StringId id)
{
switch (id)
{
case StringId.XtraMessageBoxCancelButtonText:
return "取消";
case StringId.XtraMessageBoxOkButtonText:
return "确定";
case StringId.XtraMessageBoxYesButtonText:
return "是";
case StringId.XtraMessageBoxNoButtonText:
return "否";
case StringId.XtraMessageBoxIgnoreButtonText:
return "忽略";
case StringId.XtraMessageBoxAbortButtonText:
return "中止";
case StringId.XtraMessageBoxRetryButtonText:
return "重试";
default:
return base.GetLocalizedString(id);
}
}
}
}
定义好之后,在系统的Program.cs的Main函数中使用如下一句:
DevExpress.XtraEditors.Controls.Localizer.Active = new LocalizationCHS();
效果图如下: