【问题标题】:Report Viewer control changes font on print / print preview报告查看器控件在打印/打印预览时更改字体
【发布时间】:2014-06-18 15:05:51
【问题描述】:

我用 ssrs 项目创建了一个设计精美的表单/报告,但我尝试使用 ReportViewer Class 通过 winforms 打印它,但是当我尝试打印它时(或者当我切换到打印预览时),由于某种原因,它会将其字体更改为一些看起来很奇怪的字体。
注意:我尝试在设计器和本地计算机上的 winforms 中预览它,因此行为应该没有区别。

【问题讨论】:

    标签: c# .net winforms reporting-services


    【解决方案1】:

    我不打算把它做成问答式的,但在写我的问题的过程中我想通了 :-)

    form.designer.cs 文件中包含的InitializeComponent() 方法中,您会发现Visual Studio 正在设置Control.Font Property,这会导致控件在打印时获取这些属性。

    所以我需要做的就是把它注释掉。

    请看下面我的代码示例。

        private void InitializeComponent()
        {
            this.reportViewer1 = new Microsoft.Reporting.WinForms.ReportViewer();
            this.btnRender = new System.Windows.Forms.Button();
            this.tbPickList = new System.Windows.Forms.TextBox();
            this.cbImmidiatePrint = new System.Windows.Forms.CheckBox();
            this.btnPrint = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // reportViewer1
            // 
            this.reportViewer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            //this.reportViewer1.Font = new System.Drawing.Font("Arial Rounded MT Bold", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.reportViewer1.Location = new System.Drawing.Point(12, 54);
            this.reportViewer1.Name = "reportViewer1";
            this.reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;
            this.reportViewer1.ServerReport.ReportPath = "/Reports/PackingSlips/BestBuy";
            this.reportViewer1.ServerReport.ReportServerUrl = new System.Uri("http://ssrs1/reportserver", System.UriKind.Absolute);
            this.reportViewer1.ShowToolBar = false;
            this.reportViewer1.Size = new System.Drawing.Size(999, 641);
            this.reportViewer1.TabIndex = 0;
        }
    

    【讨论】:

    • 我不知道为什么,但是当我在 vb.net 中这样做时 - 字体仍然与报告中的不同。这令人沮丧
    • 对不起@Bobski 但我没有这个项目了,但你应该知道它本身不会发生任何事情,你只需要找到执行它的代码行......另一段建议,我发现水晶报告在编写可打印表单时更有用,我不确定这是否是您的意图......
    • 我知道自己什么都不会发生 - 我评论了我的和同样的事情。谢谢
    • 尝试在那里显式输入你的字体,看看它是否有效?
    猜你喜欢
    • 1970-01-01
    • 2013-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-06
    • 1970-01-01
    相关资源
    最近更新 更多