2016-11-25 142 views
0

我是Crystal Reports的noob。我有一個DataGridView DataTable中獲取信息,下面的代碼:Crystal Reports只顯示一條記錄

Dim dt As New DataTable 
     With dt 
      .Columns.Add("ID") 
      .Columns.Add("Nombre") 
      .Columns.Add("Cantidad") 
      .Columns.Add("Descripcion") 
      .Columns.Add("Fecha") 
      .Columns.Add("Modulo") 

     End With 
     Dim rptDoc As CrystalDecisions.CrystalReports.Engine.ReportDocument 
     rptDoc = New mello 
     For Each dr As DataGridViewRow In dgvDatos.Rows 
      dt.Rows.Add(dr.Cells(0).Value, dr.Cells(1).Value, dr.Cells(2).Value, dr.Cells(3).Value, dr.Cells(4).Value, dr.Cells(5).Value) 
      rptDoc.SetDataSource(dt) 
      Crystalino.CrystalReportViewer1.ReportSource = rptDoc 
     Next 
     ' 
     Crystalino.ShowDialog() 
     Crystalino.Dispose() 

但是,當我運行程序,它顯示了一條記錄:

enter image description here

所以,我會apreciate如果你們可以幫我

+2

首先,什麼類型的對象是'mello'?其次,取出'Crystalino.CrystalReportViewer1.ReportSource = rptDoc'行,並將其放在'Next'後面。 – David

+0

'mello'是一個水晶報表。謝謝。 – screenhot1111

+0

這是否解決了這個問題? – David

回答

1

你把你的行數據放在報表設計器的details部分嗎?

如果你把你的數據放在其他部分,它只會顯示第一個結果而不是所有的數據。你需要把你的數據放在細節部分,使crystalreport獲取你的數據(你的案例中的行數據)