参数字段当前值异常未处理

时间:2018-09-29 07:53:09

标签: vb.net crystal-reports

我的程序出现问题,当我单击打印按钮时,它总是显示此错误Sample error,我现在不知道该怎么办。 这是代码,这是我的参数sample parameters

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    CrystalReportViewer1.ShowPrintButton = False

    For Each ctrl As Control In CrystalReportViewer1.Controls
        If TypeOf ctrl Is Windows.Forms.ToolStrip Then
            Dim btnNew As New ToolStripButton
            btnNew.Text = "PRINT"
            btnNew.ToolTipText = "Print Reciept"
            CType(ctrl, ToolStrip).Items.Insert(0, btnNew)

            AddHandler btnNew.Click, AddressOf printClick
        End If
    Next
End Sub

Private Sub printClick(sender As Object, e As EventArgs)
    Dim PrintDialog As New PrintDialog

    If PrintDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
        CrystalReport11.PrintOptions.PrinterName = PrintDialog.PrinterSettings.PrinterName
        CrystalReport11.PrintToPrinter(1, False, 0, 0) 'this is where the error coming up'
        Transact()
    End If
End Sub

   Private Sub btnSlip_Click(sender As Object, e As EventArgs) Handles btnSlip.Click


    Dim reportDocument As CrystalDecisions.CrystalReports.Engine.ReportDocument
    reportDocument = New CrystalReport1
    reportDocument.Refresh()
    reportDocument.SetDataSource(dt)
    reportDocument.SetParameterValue(0, ComboBox2.Text)
    reportDocument.SetParameterValue(1, TextBox1.Text)
    Form2.CrystalReportViewer1.ReportSource = reportDocument
    Form2.ShowDialog()
    Form2.Dispose()
    Form2.WindowState = FormWindowState.Maximized

End Sub

0 个答案:

没有答案