码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-08-21 16:39:44      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   strong   for   ar   div   

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     }

 

修改DevExpress中英文提示,将英文改为中文,布布扣,bubuko.com

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

标签:style   blog   color   io   strong   for   ar   div   

原文地址:http://www.cnblogs.com/DeepLearing/p/3927358.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!