简体   繁体   English

vb2005水晶报表:未声明名称“ CrystalReportViewer1”

[英]vb2005 crystal reports : Name 'CrystalReportViewer1' is not declared error

I'm running through this tutorial found here: 我正在浏览本教程,网址为:

http://vb.net-informations.com/crystal-report/vb.net_crystal_report_from_multiple_tables.htm http://vb.net-informations.com/crystal-report/vb.net_crystal_report_from_multiple_tables.htm

which teaches how to pass a parameter text field on a vb form to an embedded Crystal Report in visual studio. 它教了如何将vb表单上的参数文本字段传递给Visual Studio中的嵌入式Crystal Report。

I've followed it all the way through however when I attempt to build, I received the error: 我一直都遵循它,但是当我尝试构建时,收到了错误消息:

Name 'CrystalReportViewer1' is not declared. 未声明名称“ CrystalReportViewer1”。

So I add the line to the sub button1_click 所以我将行添加到子button1_click

Dim CrystalReportViewer1 as new CrystalReport1 

so i have 所以我有

Dim cryRpt As New ReportDocument
cryRpt.Load("c:\path\CrystalReport1.rpt")
Dim CrystalReportViewer1 As New CrystalReport1
CrystalReportViewer1.ReportSource =  cryRpt
CrystalReportViewer1.Refresh()

and then I'm ending up with a build error: 然后我以构建错误结束:

> Reference required to assembly
> 'CrystalDecisions.ReportAppServer.Controllers,Version=10.2.3600,
> Culture=neutral,
> PublicKeyToken=692fbea5521e'
> containing the type
> 'CrystalDecisions.ReportAppServer.Controllers.ReportSource'.
> Add one to your project.

I go to Project >> Add Reference and I can't find this library. 我转到项目>>添加参考,但是找不到该库。

Am I approaching this incorrectly? 我处理方法有误吗?

thanks in advance 提前致谢

Note: I did check in the help >> about to ensure that Crystal Reports for Visual Studio 2005 was installed. 注意:我确实签入了帮助>>,以确保已安装Visual Studio 2005的Crystal Reports。

One problem I suspect is that you're creating the CrystalReportViewer object (your CrystalReportViewer1 ) incorrectly. 我怀疑一个问题是您创建的CrystalReportViewer对象(您的CrystalReportViewer1 )不正确。

Rather than creating this object via declaration in your code, perhaps you need to create one by dragging and dropping the control onto your form's design surface from the toolbox. 与其通过代码中的声明来创建该对象,还不如通过将控件从工具箱拖放到窗体的设计图面上来创建该对象。

Key part of the tutorial 本教程的关键部分

and drag a button and CrystalReportViewer control to your form. 并将一个按钮和CrystalReportViewer控件拖到您的窗体。

Get rid of this: 摆脱这个:

Dim CrystalReportViewer1 as new CrystalReport1

You need to add the crystal report viewer control and it will automatically call it "CrystalReportViewer1" 您需要添加Crystal Report Viewer控件,它将自动将其称为“ CrystalReportViewer1”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM