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


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

     1 /// <summary>
     2     ///  重写DX弹出框 英文变为中文
     3     /// </summary>
     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 或其他的英文字符,替换为中文.

    /// <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);
            }
    
        } 
     1   /// <summary>
     2         ///  DX控件 自定义名称
     3         /// </summary> 
     4         public static Dictionary<GridStringId, string> SetGridLocalizer(GridStringId[] grid, params string[] str)
     5         {
     6             Dictionary<GridStringId, string> LocalizedKeyValue = new Dictionary<GridStringId, string>();
     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         /// <summary>
     4         /// 将GridControl搜索按钮 英文变为中文
     5         /// </summary>
     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     }
  • 相关阅读:
    顺序程序设计03 零基础入门学习C语言09
    数据类型,运算符和表达式05 零基础入门学习C语言06
    顺序程序设计01 零基础入门学习C语言07
    顺序程序设计01 零基础入门学习C语言07
    顺序程序设计02 零基础入门学习C语言08
    数据类型,运算符和表达式05 零基础入门学习C语言06
    分支程序设计01 零基础入门学习C语言10
    分支程序设计01 零基础入门学习C语言10
    VC++ 实现线程注入
    ISV 客户博客系列:Minitab通过Windows Azure推出云端Qeystone
  • 原文地址:https://www.cnblogs.com/DeepLearing/p/3927358.html
Copyright © 2020-2023  润新知