数据表项未显示在Crystal Report中

时间:2016-12-27 04:31:19

标签: vb.net crystal-reports

所以我在vs2010中有一个项目,并尝试使用Crystal Report打印收据。我有这个列表视图,其中显示了所有购买的项目,这些项目将通过DataSet的DataTable发送到Cyrstal报告,但它不会显示。请有人告诉我我的代码有什么问题。

设计

enter image description here

rpt输出未显示listview中的列表

enter image description here

    Private Sub orForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim myOR As New salesReceipt
        Dim cashier As TextObject = myOR.ReportDefinition.ReportObjects("Text11")
        Dim dtm As TextObject = myOR.ReportDefinition.ReportObjects("Text12")

        Dim ds As New DataSet
        Dim dt As New DataTable
        ds.Tables.Add(dt)
        With dt
            .Columns.Add("Items")
            .Columns.Add("Quantity")
            .Columns.Add("Total")
        End With
        For i As Integer = 0 To main.lvItemsToPurchase.Items.Count - 1
            Dim dr As DataRow = dt.NewRow
            dr("Items") = main.lvItemsToPurchase.Items.Item(i).SubItems(1).Text
            dr("Quantity") = main.lvItemsToPurchase.Items.Item(i).SubItems(3).Text
            dr("Total") = main.lvItemsToPurchase.Items.Item(i).SubItems(5).Text
            dt.Rows.Add(dr)
        Next

        cashier.Text = "Cashier: " & curUser
        dtm.Text = "Date/Time: " & Format(Now, "MMMM dd, yyyy") & " " & FormatDateTime(Now, DateFormat.LongTime)
        myOR.SetDataSource(ds)
        CrystalReportViewer1.ReportSource = myOR
    End Sub

1 个答案:

答案 0 :(得分:0)

使用myOR.SetDataSource(ds.Tables(0)),数据集包含多个数据表,因此您应在数据集中指定数据表