如何在Crystal Report中清除或处理当前页面?

时间:2015-07-24 03:10:46

标签: vb.net crystal-reports

目前,我可以通过Button1在CrystalReportViewer1中生成报告。 如何删除报告的当前内容。我需要在上面打印另一条记录。

即时通讯使用VB.net

Dim rep As WorkFileTags1 = New WorkFileTags1()
    CrystalReportViewer1.ReportSource = Nothing
    rep.Refresh()
    Connect()
    reader = New SqlCommand("select     c_sfr,c_pn,c_sn,c_po,c_dateReceived,c_received from tbl_workfile where c_sfr = '" & ComboBox1.Text & "' ", conn).ExecuteReader
    DT.Load(reader)
    rep.SetDataSource(DT)
    CrystalReportViewer1.ReportSource = rep

1 个答案:

答案 0 :(得分:1)

您可以将ReportSource设置为Nothing,然后使用Refresh()重新加载ReportViewer。

Dim rep As WorkFileTags1 = New WorkFileTags1()
CrystalReportViewer1.ReportSource = Nothing
rep.Refresh()
Connect()
reader = New SqlCommand("select     c_sfr,c_pn,c_sn,c_po,c_dateReceived,c_received from tbl_workfile where c_sfr = '" & ComboBox1.Text & "' ", conn).ExecuteReader
DT.Load(reader)
rep.SetDataSource(DT)
CrystalReportViewer1.ReportSource = rep

您可以添加一个按钮来清除它,并将以下内容添加到按钮的事件

CrystalReportViewer1.ReportSource = Nothing CrystalReportViewer1.Refresh()