Visual Studio 2017 RC 中缺少 Reportviewer 工具

人气:765 发布:2022-10-16 标签: c# wpf windows-forms-designer visual-studio-2017

问题描述

我刚开始在名为 Visual Studio 2017 RC 的新版 Visual Studio 中编写报告软件,但刚刚注意到 Windows 窗体和 WPF 应用程序模板中缺少核心报告查看工具.谁能告诉我为什么 reportviewer 工具从 Visual Studio 2017 中消失了?没有它真的很麻烦.在新的视觉工作室中是否有任何替代方法可以使用此工具?

I just started to write reporting software in new version of visual studio named visual studio 2017 RC but just noticed that core reportviewing tools is missing from both windows forms and WPF application template. Can anyone tell me why the reportviewer tool is disappeared from visual studio 2017 ? Really having trouble without it . Is there any alternate to work with this tool in new visual studio ?

推荐答案

** 更新**:11/19/2019

** Update**: 11/19/2019

Microsoft 已在其 Nuget 库中发布了新版本的控件 150.1400.0.我的简短测试表明它在 150.1357.0150.1358.0 没有的表单设计器中再次起作用.这包括能够调整和修改控件本身的 ReportViewer 任务.

Microsoft has released a new version of the control 150.1400.0 in their Nuget library. My short testing shows that it works again in the forms designer where 150.1357.0 and 150.1358.0 did not. This includes being able to resize and modify the ReportViewer Tasks on the control itself.

** 更新**:2019 年 8 月 18 日

** Update**: 8/18/2019

删除最新版本并回滚到 150.900.148.0 似乎适用于我使用 VS2017 和 VS2019 的多台计算机.

Removing the latest version and rolling back to 150.900.148.0 seems to work on multiple computers I'm using with VS2017 and VS2019.

您可以在 Nuget 解决方案包管理器中回滚到 150.900.148.它的工作原理与以前的版本类似.使用下拉框选择旧版本.

You can roll back to 150.900.148 in the Nuget solution package manager. It works similarly to the previous versions. Use the drop down box to select the older version.

手动删除对 150.900 版本 ReportViewer 的引用并重新读取它们可能比修复它们更容易.

It may be easier to manually delete references to post 150.900 versions of ReportViewer and readd them than it is to fix them.

请记住在更改工具箱条目后重新启动 Visual Studio.

Remember to restart Visual Studio after changing the toolbox entry.

更新:2019 年 8 月 7 日

Update: 8/7/2019

ReportViewer 控件的较新版本已发布,可能与 Visual Studio 2019 同步发布.我使用的是 V150.1358.0.

A newer version of the ReportViewer control has been released, probably coinciding with Visual Studio 2019. I was working with V150.1358.0.

按照此答案中的说明获得设计器工具箱中的控件.但是一旦放在表单上它就不会显示.该控件作为非可视组件显示在表单下方.

Following the directions in this answer gets the control in the designer's toolbox. But once dropped on the form it doesn't display. The control shows up below the form as a non-visual component.

这是根据 Microsoft SQL BI 支持设计的.这是负责控制的组.

This is working as designed according to Microsoft SQL BI support. This is the group responsible for the control.

虽然您仍然无法直接与控件交互,但这些附加步骤提供了一种解决方法,因此可以在窗体上调整控件的大小.虽然现在可见,但设计器将控件视为不存在.

While you still cannot interact with the control directly, these additional steps give a workaround so the control can be sized on the form. While now visible, the designer treats the control as if it didn't exist.

我根据 Microsoft SQL BI 支持的建议创建了一个反馈请求.请考虑对其进行投票以引起 Microsoft 的注意.

I've created a feedback request at the suggestion of Microsoft SQL BI support. Please consider voting on it to get Microsoft's attention.

Microsoft Azure 反馈页面 - 恢复 WinForms ReportViewer 控件的设计时功能

其他步骤:

将报表查看器添加到 WinForm 后将面板控件添加到 WinForm.

在表单的 form.designer.cs 文件中,将 Reportviewer 控件添加到面板中. After adding the reportviewer to the WinForm Add a Panel Control to the WinForm.

In the form's form.designer.cs file, add the Reportviewer control to the panel.

  // 
  // panel1
  // 
  this.panel1.Controls.Add(this.reportViewer1);

返回表单设计器,您应该会在面板上看到reportViewer

Return to the form's designer, you should see the reportViewer on the panel

现在您可以通过实际与面板交互来定位 reportViewer.

Now you can position the reportViewer by actually interacting with the panel.

更新:微软发布了文档,2017 年 4 月 18 日,描述了如何在 Visual Studio 2017 中配置和使用报告工具.

Update: Microsoft released a document on April 18, 2017 describing how to configure and use the reporting tool in Visual Studio 2017.

Visual Studio 2017 的工具箱中默认没有安装 ReportViewer 工具.安装扩展 Microsoft Rdlc Report Designer for Visual Studio,然后将其添加到 ToolBox 会导致出现在表单下方的非可视组件.

Visual Studio 2017 does not have the ReportViewer tool installed by default in the ToolBox. Installing the extension Microsoft Rdlc Report Designer for Visual Studio and then adding that to the ToolBox results in a non-visual component that appears below the form.

Microsoft 支持告诉我这是一个错误,但截至 2017 年 4 月 21 日,它按设计工作".

Microsoft Support had told me this is a bug, but as of April 21, 2017 it is "working as designed".

每个需要ReportViewer的项目都需要遵循以下步骤.

The following steps need to be followed for each project that requires ReportViewer.

如果工具箱中有 ReportViewer,请将其删除.突出显示,右键单击并删除.您必须有一个打开表单的项目才能执行此操作. If you have ReportViewer in the Toolbox, remove it. Highlight, right-click and delete. You will have to have a project with a form open to do this.

于 2019 年 8 月 7 日编辑 - 看起来当前版本的 RDLC 报表设计器扩展不再干扰.您需要它来实际编辑报告.

Edited 8/7/2019 - It looks like the current version of the RDLC Report Designer extension no longer interferes. You need this to actually edit the reports.

如果您安装了 Microsoft Rdlc Report Designer for Visual Studio 扩展,请将其卸载.

If you have the Microsoft Rdlc Report Designer for Visual Studio extension installed, uninstall it.

关闭您的解决方案并重新启动 Visual Studio.这是很关键的一步,如果VS没有重启就会报错在解决方案之间切换.

Close your solution and restart Visual Studio. This is a crucial step, errors will occur if VS is not restarted when switching between solutions.

在 PM> 提示符下输入此命令,大小写很重要.

At the PM> prompt enter this command, case matters.

安装包 Microsoft.ReportingServices.ReportViewerControl.WinForms

您应该会看到描述包安装的文字.

You should see text describing the installation of the package.

现在我们可以暂时将ReportViewer工具添加到工具箱中.

Now we can temporarily add the ReportViewer tool to the tool box.

在工具箱中右击并使用Choose Items...

我们需要浏览到位于解决方案 Packages 文件夹中的正确 DLL,因此请点击浏览按钮.

We need to browse to the proper DLL that is located in the solutions Packages folder, so hit the browse button.

在我们的示例中,我们可以粘贴到包文件夹中,如包管理器控制台的文本所示.

In our example we can paste in the packages folder as shown in the text of Package Manager Console.

C:UsersjdoeDocumentsProjects\_TestReportViewerTestWindowsFormsApp1packages

然后双击名为Microsoft.ReportingServices.ReportViewerControl.Winforms.140.340.80

未来版本号可能会改变.

The version number will probably change in the future.

然后双击 lib 并再次双击 net40.

Then double-click on lib and again on net40.

最后,双击文件Microsoft.ReportViewer.WinForms.dll

您应该会在对话框中看到 ReportViewer 已选中.滚动到右侧,您将看到与之关联的版本 14.0.0.0.

You should see ReportViewer checked in the dialog. Scroll to the right and you will see the version 14.0.0.0 associated to it.

点击确定.

ReportViewer 现在位于工具箱中.

将工具拖到所需的表单上.

Drag the tool to the desired form(s).

完成后,从工具箱中删除 ReportViewer 工具.您不能将其用于其他项目.

Once completed, delete the ReportViewer tool from the tool box. You can't use it with another project.

您可以保存项目,一切顺利.

You may save the project and are good to go.

记得在您需要使用 ReportViewer 打开项目时重新启动 Visual Studio,以便从正确的位置加载 DLL.如果您尝试使用带有 ReportViewer 的表单打开解决方案而不重新启动,您将看到错误提示变量 'reportViewer1' 未声明或从未分配.".

Remember to restart Visual Studio any time you need to open a project with ReportViewer so that the DLL is loaded from the correct location. If you try and open a solution with a form with ReportViewer without restarting you will see errors indicating that the "The variable 'reportViewer1' is either undeclared or was never assigned.".

如果您将新项目添加到您需要创建项目的同一解决方案中,保存解决方案,重新启动 Visual Studio,然后您应该能够将 ReportViewer 添加到表单中.我第一次看到它不起作用并显示为非可视组件.

If you add a new project to the same solution you need to create the project, save the solution, restart Visual Studio and then you should be able to add the ReportViewer to the form. I have seen it not work the first time and show up as a non-visual component.

当这种情况发生时,从表单中删除组件,从项目中删除 Microsoft.ReportViewer.* 引用,保存并重新启动通常可以工作.

When that happens, removing the component from the form, deleting the Microsoft.ReportViewer.* references from the project, saving and restarting usually works.

785