报表查看器控件在打印/打印预览上更改字体

时间:2014-06-18 15:05:51

标签: c# .net winforms reporting-services

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

1 个答案:

答案 0 :(得分:1)

我不打算把它作为Q& A风格,但在写我的问题的中间我想出来了:-)

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

form.designer.cs

所以我需要做的就是评论它。

请参阅下面的代码示例。

    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;
    }
相关问题