在项目开发中,我们总是会用到rdlc报表设计器,大多数情况下在本地开发环境中工具栏按钮显示的是中文,但是部署到客户环境后发现显示的是英文。

  解决这个问题也是走了很多弯路,给大家简单说一下:

  1、最初以为安装.NET Framework 的语言包就可以解决问题,但是后来发现ReportViewer不属于.NET类库,它属于VS中的一个插件,所以安装NET Framework 的语言包语言包根本就不能解决问题。所以就想有没有ReportViewer的语言包,网上说有,官网中也有下载的,但是安装后并没有解决我的问题。

  2、系统环境安装VS2008后在C:\Windows\assembly下边有几个资源文件,说是拷贝到C:\Windows\assembly\GAC_MSIL下就可以,试了并没有什么用。

  3、下边就是最简单,最有效的方法,在你的项目下新建一个类,类名称随意,符合C#代码命名规则即可,继成接口IReportViewerMessages。然后写代码:


public class ReportViewerMessages: IReportViewerMessages
{


  #region IReportViewerMessages Members

        public string BackButtonToolTip
        {
            get { return ("返回"); }
        }

        public string BackMenuItemText
        {
            get { return ("返回"); }
        }

        public string ChangeCredentialsText
        {
            get { return ("Add your custom text here."); }
        }

        public string CurrentPageTextBoxToolTip
        {
            get { return ("当前页"); }
        }

        public string DocumentMapButtonToolTip
        {
            get { return ("文档结构"); }
        }

        public string DocumentMapMenuItemText
        {
            get { return ("文档结构"); }
        }

        public string ExportButtonToolTip
        {
            get { return ("导出"); }
        }

        public string ExportMenuItemText
        {
            get { return ("导出"); }
        }

        public string FalseValueText
        {
            get { return ("FalseValueText"); }
        }

        public string FindButtonText
        {
            get { return ("查找"); }
        }

        public string FindButtonToolTip
        {
            get { return ("查找"); }
        }

        public string FindNextButtonText
        {
            get { return ("下一个"); }
        }

        public string FindNextButtonToolTip
        {
            get { return ("下一个"); }
        }

        public string FirstPageButtonToolTip
        {
            get { return ("首页"); }
        }

        public string LastPageButtonToolTip
        {
            get { return ("最后一页"); }
        }

        public string NextPageButtonToolTip
        {
            get { return ("下一页"); }
        }

        public string NoMoreMatches
        {
            get { return ("无其他匹配项"); }
        }

        public string NullCheckBoxText
        {
            get { return ("NullCheckBoxText"); }
        }

        public string NullCheckBoxToolTip
        {
            get { return ("NullCheckBoxToolTip"); }
        }

        public string NullValueText
        {
            get { return ("NullValueText"); }
        }

        public string PageOf
        {
            get { return ("/"); }
        }

        public string PageSetupButtonToolTip
        {
            get { return ("页面设置"); }
        }

        public string PageSetupMenuItemText
        {
            get { return ("页面设置"); }
        }

        public string ParameterAreaButtonToolTip
        {
            get { return ("ParameterAreaButtonToolTip"); }
        }

        public string PasswordPrompt
        {
            get { return ("PasswordPrompt"); }
        }

        public string PreviousPageButtonToolTip
        {
            get { return ("上一页"); }
        }

        public string PrintButtonToolTip
        {
            get { return ("打印"); }
        }

        public string PrintLayoutButtonToolTip
        {
            get { return ("打印布局"); }
        }

        public string PrintLayoutMenuItemText
        {
            get { return ("打印布局"); }
        }

        public string PrintMenuItemText
        {
            get { return ("打印"); }
        }

        public string ProgressText
        {
            get { return ("正在生成报表"); }
        }

        public string RefreshButtonToolTip
        {
            get { return ("刷新"); }
        }

        public string RefreshMenuItemText
        {
            get { return ("刷新"); }
        }

        public string SearchTextBoxToolTip
        {
            get { return ("在报表中查找文本"); }
        }

        public string SelectAValue
        {
            get { return ("SelectAValue"); }
        }

        public string SelectAll
        {
            get { return ("SelectAll"); }
        }

        public string StopButtonToolTip
        {
            get { return ("停止"); }
        }

        public string StopMenuItemText
        {
            get { return ("停止"); }
        }

        public string TextNotFound
        {
            get { return ("Add your custom text here."); }
        }

        public string TotalPagesToolTip
        {
            get { return ("全部页"); }
        }

        public string TrueValueText
        {
            get { return ("Add your custom text here."); }
        }

        public string UserNamePrompt
        {
            get { return ("Add your custom text here."); }
        }

        public string ViewReportButtonText
        {
            get { return ("Add your custom text here."); }
        }

        public string ViewReportButtonToolTip
        {
            get { return ("Add your custom text here."); }
        }

        public string ZoomControlToolTip
        {
            get { return ("缩放"); }
        }

        public string ZoomMenuItemText
        {
            get { return ("缩放"); }
        }

        public string ZoomToPageWidth
        {
            get { return ("页宽"); }
        }

        public string ZoomToWholePage
        {
            get { return ("整页"); }
        }

        #endregion
}
 

  最后,在你放置ReportViewer的那个界面的Load事件或者页面构造方法里边增加一行代码:ReportViewer1.Messages = new ReportViewerMessages();

posted on 2020-09-15 15:02  振仔仔  阅读(691)  评论(0编辑  收藏  举报