2017-10-11 130 views
0

我在Windows应用程序中使用Crystal Reports 14.2.2.1975和Visual Studio 2015。Crystal Reports:无法在查看器中刷新页面或刷新

我已经能够成功创建基于与DataTable匹配的字段定义的报告。该报告打印完美,并且可以正确预览 - 但是 - 当试图在查看器中使用刷新或分页控件时,它会再次提示我输入所有报告参数,然后显示示例数据而不是请求的页面。

设置查看器的代码是从另一个对话框窗体(FrmPrint)调用的。在FrmPrint的 “预览” 按钮的相关代码...

Dim crxReport As New ReportDocument 
crxReport.Load("<path>\Sample Report.rpt") 

... 

<a dataTable (dt) is created and loaded with the proper data> 

... 


' Set the data source of the report to that dataTable 
crxReport.Database.Tables(0).SetDataSource(dt) 

' Prepare to preview the report 
(viewer contained on a separate form, "FrmReportPreview") 
With FrmReportPreview 
    .Text = "My report name" 
    .CrystalReportViewer1.ReuseParameterValuesOnRefresh = True 
    .CrystalReportViewer1.ReportSource = crxReport 
    .CrystalReportViewer1.Show() 
End With 

' Show the report preview window 
FrmReportPreview.Show() 

回答

0

原来,问题是最后一行:

frmReportPreview.Show() ' A modeless dialog 

当改为:

frmReportPreview.ShowDialog() ' Making it modal 

..问题消失。