关于如何将其设置为“FOR LOOP”的任何想法,因为我想要显示的数据的数量不固定或不变,所以我需要将其设置为for循环。
Public Sub ReportTransactionsLogs(ByVal LV As ListView)
Dim rReport As New ReportTransLog
Dim row As DataRow = Nothing
Dim ds As New DataSet
ds.Tables.Add("TransactionsLog")
With ds.Tables(0).Columns
.Add("Username")
.Add("ActionDate")
.Add("ActionTime")
.Add("Activity")
.Add("POInvoice")
End With
For Each LVI As ListViewItem In LV.Items
row = ds.Tables(0).NewRow
row(0) = LVI.Text
row(1) = LVI.SubItems(1).Text
row(2) = LVI.SubItems(2).Text
row(3) = LVI.SubItems(3).Text
row(4) = LVI.SubItems(4).Text
ds.Tables(0).Rows.Add(row)
Next
rReport.SetDataSource(ds.Tables(0))
ReportViewer.CrystalReportViewer1.ReportSource = rReport
End Sub
答案 0 :(得分:0)
试试这个..
For Each LVI As ListViewItem In LV.Items row = ds.Tables(0).NewRow
For i As Integer = 1 To ds.Table(0).Columns.Count()
If InlineAssignHelper(i, 0) Then
row(i) = LVI.Text
Else
row(i) =LVI.SubItems(i).Text
End If
Next
Next