我无法让报告查看器在 VS 2019 上工作 [英] I can not get the report viewer to work on VS 2019

查看:25
本文介绍了我无法让报告查看器在 VS 2019 上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio 2019 上,我从 NuGet 包中添加了 Microsoft RDLC 报告设计器,我继续将 Microsoft.ReportViewer.Winforms.dll 添加到项目中.我还创建了一个 .xsd 和一个 .rdlc.reportviewer 工具显示在我的工具箱上,我可以将它拖放到表单上.问题是,当我将报表查看器工具放到我的表单上时,它不会打开报表视图.相反,它会出现在表单的底部,就像计时器工具一样.我双击它,它什么也没做.我在 VS 2017 上遵循了相同的步骤,并且能够创建报告.

On Visual Studio 2019 I have added the Microsoft RDLC Report Designer from NuGet packages and I went ahead and added the Microsoft.ReportViewer.Winforms.dll to the project as well. I also created a .xsd and a .rdlc The reportviewer tool shows up on my toolbox and I am able to drag and drop it onto the form. The problem is, when I drop the report viewer tool onto my form, it doesn't open the report view. Instead, it goes to the bottom of the form, just like the timer tool does. I double click on it and it does nothing. I followed the same steps on VS 2017 and was able to create a report.

我已经卸载了这些软件包并重新安装了它们,它的行为一直保持不变.

I already uninstalled the packages and re-installed them and it keeps behaving the same way.

我希望报告查看器的显示方式与 VS 2017 中的一样

I expect the report viewer to display as it did in VS 2017

推荐答案

我使用的是 150.1404.0 版本,但问题仍然存在.该错误不在报告控件中,它是 VS2019 代码生成器错误.代码缺少实际在表单上添加控件的行:

I'm using version 150.1404.0 and the issue is still present. The bug is not in the reporting control, it is a VS2019 code generator bug. The code lacks the line that actually adds the control on the form:

this.Controls.Add(reportViewer1);

这个需要放在控件初始化之后,之前

This needs to be placed after the control was initialized and before the

this.ResumeLayout(false);

InitializeComponent() 方法中的一行,可以在 formName.Designer.cs 中找到

line in the InitializeComponent() method, which can be found in the formName.Designer.cs

这篇关于我无法让报告查看器在 VS 2019 上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆