Question Can't load data from Datagridview to Crystal Report

hungnth27

New member
Joined
Dec 24, 2015
Messages
1
Location
Vietnam
Programming Experience
Beginner
Hi all, i have a project: load data from excel file to datagridview (DGV1) and I have 2 datagridview (DGV1 and DGV2). After click a row from DGV1, data row from DGV1 will be displayed to DGV2. Now, i cant display export data from DGV2 to Crystal Report. But, with this code, i try display data from DGV1, it's normal.
Can someone help me resolved? :(
This is my code:

Private Sub dgvExcelShow_MouseClick(sender As Object, e As MouseEventArgs) Handles dgvExcelShow.MouseClick
TakeData()
End Sub

Private Sub TakeData()
If dgvExcelShow.RowCount = 0 Or Nothing Then
Else
If dgvExcel_Row.RowCount = 0 Then
For Each cell As DataGridViewColumn In dgvExcelShow.Columns
dgvExcel_Row.Columns.Add(DirectCast(cell.Clone, DataGridViewColumn))
Next
End If
dgvExcel_Row.Rows.Add(dgvExcelShow.CurrentRow.Cell s.Cast(Of DataGridViewCell).Select(Function(c) c.Value).ToArray)
End If
End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
dt = Me.dgvExcel_Row.DataSource
Dim Report As New CrystalReport_Test
Report.SetDataSource(dt)

Dim R As New Form2

R.CrystalReportViewer1.ReportSource = Report
R.ShowDialog()
End Sub
 
Back
Top