在报告中打印参数

时间:2013-02-07 08:05:23

标签: vb.net report reportviewer

这是我的VB.NET(2012)代码,用于显示基于Combobox (cmbCustomer)选择的报告,我想在报告上打印该参数cmbCustomer.text。 / p>

Private Sub btnShow_Click(sender As Object, e As EventArgs) Handles btnShow.Click
        Me.rpt_customerByDateTableAdapter.Fill(Me.customerByDateDataSet.rpt_customerByDate,
        cmbCustomer.Text)
        Me.ReportViewer1.RefreshReport()
End Sub

1 个答案:

答案 0 :(得分:0)

以下是假设您已在rldc

中创建参数的方法
Dim customer As String = cmbCustomer.text
Dim CustomerParam As New ReportParameter("yourCustomerParameter", customer)

Dim reportParameters() As ReportParameter = {CustomerParam}

Me.DataTable1TableAdapter.Fill(Me.customerByDateDataSet.rpt_customerByDate,
        cmbCustomer.Text)

Me.ReportViewer1.LocalReport.SetParameters(reportParameters)
Me.ReportViewer1.RefreshReport()