代码改变世界

DevExpress 相关右键菜单汉化

2012-04-08 16:59  thtfria  阅读(715)  评论(0编辑  收藏  举报

1、首先在窗体的构造函数中重新定义控件的活动属性(看不懂可以联系本人个人资料里有MSN和QQ)
例如要修改GridControl列的右键菜单

GridLocalizer.Active = new XtraGridLocalizationCHS();

然后在另外一个类里面定义如下

public class XtraGridLocalizationCHS : GridLocalizer
        {
            public override string GetLocalizedString(GridStringId id)
            {
                switch (id)
                {
                    case GridStringId.CardViewNewCard:
                        return "新卡片";
                    case GridStringId.CardViewQuickCustomizationButton:
                        return "自定义格式";
                    case GridStringId.CardViewQuickCustomizationButtonFilter:
                        return "筛选";
                    case GridStringId.CardViewQuickCustomizationButtonSort:
                        return "排序:";
                    case GridStringId.ColumnViewExceptionMessage:
                        return "是否确定修改?";
                    case GridStringId.CustomFilterDialog2FieldCheck:
                        return "字段";
                    case GridStringId.CustomFilterDialogCancelButton:
                        return "取消(&C)";
                    case GridStringId.CustomFilterDialogCaption:
                        return "条件为:";
                    case GridStringId.CustomFilterDialogClearFilter:
                        return "清除筛选条件(&L)";
                    case GridStringId.CustomFilterDialogConditionBlanks:
                        return "空值";
                    case GridStringId.CustomFilterDialogConditionEQU:
                        return "等于=";
                    case GridStringId.CustomFilterDialogConditionGT:
                        return "大于>";
                    case GridStringId.CustomFilterDialogConditionGTE:
                        return "大于或等于>=";
                    case GridStringId.CustomFilterDialogConditionLT:
                        return "小于<";
                    case GridStringId.CustomFilterDialogConditionLTE:
                        return "小于或等于<=";
                    case GridStringId.CustomFilterDialogConditionLike:
                        return "包含";
                    case GridStringId.CustomFilterDialogConditionNEQ:
                        return "不等于<>";
                    case GridStringId.CustomFilterDialogConditionNonBlanks:
                        return "非空值";
                    case GridStringId.CustomFilterDialogConditionNotLike:
                        return "不包含";
                    case GridStringId.CustomFilterDialogFormCaption:
                        return "自定义筛选条件";
                    case GridStringId.CustomFilterDialogOkButton:
                        return "确定(&O)";
                    case GridStringId.CustomFilterDialogRadioAnd:
                        return "并且";
                    case GridStringId.CustomFilterDialogRadioOr:
                        return "或者";
                    case GridStringId.CustomizationBands:
                        return "分区";
                    case GridStringId.CustomizationCaption:
                        return "自定义显示字段";
                    case GridStringId.CustomizationColumns:
                        return "列";
                    case GridStringId.FileIsNotFoundError:
                        return "文件{0}没有找到";
                    case GridStringId.FilterBuilderApplyButton:
                        return "应用";
                    case GridStringId.FilterBuilderCancelButton:
                        return "取消";
                    case GridStringId.FilterBuilderCaption:
                        return "筛选编辑器";
                    case GridStringId.FilterBuilderOkButton:
                        return "确定";
                    case GridStringId.FilterPanelCustomizeButton:
                        return "自定义";
                    case GridStringId.GridGroupPanelText:
                        return "";
                    case GridStringId.GridNewRowText:
                        return "新增资料";
                    case GridStringId.GridOutlookIntervals:
                        return "一个月以上;上个月;三周前;两周前;上周;;;;;;;;昨天;今天;明天; ;;;;;;;下周;两周后;三周后;下个月;一个月之后;";
                    case GridStringId.MenuColumnBestFit:
                        return "最佳匹配";
                    case GridStringId.MenuColumnBestFitAllColumns:
                        return "最佳匹配所有字段";
                    case GridStringId.MenuColumnClearFilter:
                        return "清除筛选条件";
                    case GridStringId.MenuColumnClearSorting:
                        return "清除排序";
                    case GridStringId.MenuColumnColumnCustomization:
                        return "显示/隐藏字段";
                    case GridStringId.MenuColumnRemoveColumn:
                        return "删除此列";
                    case GridStringId.MenuColumnFilter:
                        return "筛选";
                    case GridStringId.MenuColumnFilterEditor:
                        return "筛选编辑器";
                    case GridStringId.MenuColumnGroup:
                        return "按此列分组";
                    case GridStringId.MenuColumnGroupBox:
                        return "显示/隐藏分组区";
                    case GridStringId.MenuColumnSortAscending:
                        return "升序排序";
                    case GridStringId.MenuColumnSortDescending:
                        return "降序排序";
                    case GridStringId.MenuColumnUnGroup:
                        return "取消分组";
                    case GridStringId.MenuFooterAverage:
                        return "平均";
                    case GridStringId.MenuFooterAverageFormat:
                        return "平均={0:#.##}";
                    case GridStringId.MenuFooterCount:
                        return "计数";
                    case GridStringId.MenuFooterCountFormat:
                        return "{0}";
                    case GridStringId.MenuFooterCountGroupFormat:
                        return "计数={0}";
                    case GridStringId.MenuFooterCustomFormat:
                        return "自定={0}";
                    case GridStringId.MenuFooterMax:
                        return "最大";
                    case GridStringId.MenuFooterMaxFormat:
                        return "最大={0}";
                    case GridStringId.MenuFooterMin:
                        return "最小";
                    case GridStringId.MenuFooterMinFormat:
                        return "最小={0}";
                    case GridStringId.MenuFooterNone:
                        return "空";
                    case GridStringId.MenuFooterSum:
                        return "合计";
                    case GridStringId.MenuFooterSumFormat:
                        return "合计={0:#.##}";
                    case GridStringId.MenuGroupPanelClearGrouping:
                        return "清除所有分组";
                    case GridStringId.MenuGroupPanelFullCollapse:
                        return "收缩全部分组";
                    case GridStringId.MenuGroupPanelFullExpand:
                        return "展开全部分组";
                    case GridStringId.PopupFilterAll:
                        return "(所有)";
                    case GridStringId.PopupFilterBlanks:
                        return "(空值)";
                    case GridStringId.PopupFilterCustom:
                        return "(自定义)";
                    case GridStringId.PopupFilterNonBlanks:
                        return "(非空值)";
                    case GridStringId.PrintDesignerBandHeader:
                        return "区标题";
                    case GridStringId.PrintDesignerBandedView:
                        return "打印设置(区域模式)";
                    case GridStringId.PrintDesignerCardView:
                        return "打印设置(卡片模式)";
                    case GridStringId.PrintDesignerDescription:
                        return "为当前视图设置不同的打印选项.";
                    case GridStringId.PrintDesignerGridView:
                        return "打印设置(表格模式)";
                    case GridStringId.WindowErrorCaption:
                        break;
                    default:
                        break;
                }
                return base.GetLocalizedString(id);
            }

            public override string Language
            {
                get
                {
                    return "简体中文";
                }
            }
        }