将文本框内容发送到ReportViewer .rdlc报表 [英] Sending TextBox Contents To ReportViewer .rdlc Report

查看:120
本文介绍了将文本框内容发送到ReportViewer .rdlc报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有一个发票程序,需要从中打印发票.我正在使用VB2012 RC,并且在执行此操作时遇到了麻烦.

我创建了2个报告(rptList.rdlc和rptRecord.rdlc). List.rdlc运行正常-从数据库获取所有记录并按预期显示.我遇到的问题是当前选择的记录.我不知道如何将文本框内容添加到rptRecord.rdlc报告中.

我对VB和整个编程世界都是陌生的,因此,任何帮助将不胜感激.到目前为止,我拥有的代码如下:

Hi all, I''ve got an invoice program that I need to print an invoice from. I am using VB2012 RC and am having trouble doing this.

I have created 2 reports (rptList.rdlc and rptRecord.rdlc). List.rdlc is working fine - it gets all records from the db and displays as intended. Where I have a problem is with the currently selected record. I can''t figure out how to get my textbox contents onto the rptRecord.rdlc report.

I am new to VB and the whole Programming world in general, so, any help would be greatly appreciated. The code I have thus far is as follows:

#Region " PrintReport(SelectedRow) "
    ''' <summary>
    ''' Prints the currently selected record.
    ''' </summary>
    ''' <param name="SelectedRow"></param>
    ''' <remarks></remarks>
    Public Sub PrintReport(ByVal SelectedRow As String)

        Dim ds As New myDatabase_DataSet
        Dim dt As DataTable = ds.Tables(0)
        Dim dr As DataRow = dt.NewRow()

        dr("db_id") = CInt(SelectedRow)
        dr("owner_name") = frmMain.txtOwner.Text
        dr("owner_other") = frmMain.txtOther.Text
        dr("description") = frmMain.desc.Text
        dr("make") = frmMain.txtMake.Text
        dr("model") = frmMain.txtModel.Text
        dr("serialnumber") = frmMain.txtSerialNumber.Text
        dr("time_stamp") = frmMain.lblTimeStamp.Text

        dt.Rows.Add(dr)

        With frmPrintReports
            .Show()

            .ReportViewer2.LocalReport.ReportPath = _
               Application.StartupPath & "\rptRecord.rdlc"

            .ReportViewer2.LocalReport.DataSources.Clear()

            .ReportViewer2.LocalReport.DataSources.Add(New _
               ReportDataSource("myDatabase_DataSet1", ds.Tables(0)))

            .ReportViewer2.RefreshReport()

            .ReportViewer2.Visible = True
        End With

    End Sub
#End Region ' Prints the currently selected record.




我用以下函数调用该函数:




I call the function with:

PrintReport(lblCurrentRecord.Text)



谢谢,
Bill



Thanks,
Bill

推荐答案

您的ReportViewer2.LocalReport有一个名为SetParameters的方法.创建一个新的List(Of ReportParameter),在您的报表中添加文本框内容以及该参数的名称,然后将其发送到

Your ReportViewer2.LocalReport has a method called SetParameters. Create a new List(Of ReportParameter), add your textbox contents with the name of the parameter in your report and send it in

Public Overrides Sub SetParameters(ByVal parameters As System.Collections.Generic.IEnumerable(Of Microsoft.Reporting.WinForms.ReportParameter))
     Member of Microsoft.Reporting.WinForms.LocalReport
Summary:
Sets report parameter properties for the local report.

Parameters:
parameters: An array of Microsoft.Reporting.WinForms.ReportParameter objects that contains a list of the report parameter properties.


这篇关于将文本框内容发送到ReportViewer .rdlc报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆