-
Jul 10th, 2012, 06:53 AM
#1
Thread Starter
Addicted Member
[RESOLVED] show multiple Crystal Report
Hi Guys,
I am using a for loop to view several crystal reports. but the thing is only the last one I checked is being shown. For example, if i select 3 records on the datagridview, three forms should be displayed. See the code below and hope you can advise.
Code:
Dim rptdoc As CrystalDecisions.CrystalReports.Engine.ReportDocument
rptdoc = New CrystalReport2
For i = 0 To DataGridView1.Rows.Count - 1
If DataGridView1.Item(2, i).Value = True Then
Dim localid As TextObject = rptdoc.ReportDefinition.ReportObjects("Text6")
localid.Text = DataGridView1.Item(0, i).Value.ToString
Dim barcode As TextObject = rptdoc.ReportDefinition.ReportObjects("Text8")
barcode.Text = "*" & DataGridView1.Item(0, i).Value.ToString & "*"
ViewPS94.CrystalReportViewer1.ReportSource = rptdoc
ViewPS94.Show()
'ViewPS94.Dispose()
End If
Next
-
Jul 10th, 2012, 10:32 AM
#2
Re: show multiple Crystal Report
I see a few problems with your code:
- If you want to loop through the selected rows of the DataGridView, you should be using the .SelectedRows collection.
- You declare a new report at the top of the loop, this is incorrect, you would have to create a new report for each iteration of the loop.
- Whatever 'ViewPS94' is, (not a great name, assuming it is a Form) you will also need to declare a new instance of that in the loop.
You will assign the new report you created in the loop (rptdoc) to the new form instance you created in the loop (ViewPS94) and then show it.
-
Jul 10th, 2012, 11:23 AM
#3
Thread Starter
Addicted Member
Re: show multiple Crystal Report
Hello,
Thank you loads to point out my errors. It is working fine now. I should have thought a bit more about it. Thank you so much.
For the selected row, I have placed a checkbox in the datagrid. thats y at the start of the loop, i checked if it is true or not.
Between just wanted to ask. Lets say if I have to view like 15 pdf, it will be like 15 windows opened. Is there a way to merge all these pdf in one pdf? Hope you can advise. Thanks again
-
Jul 10th, 2012, 11:30 AM
#4
Re: show multiple Crystal Report
It is possible to merge PDFs, however there is no managed way to do it. You will have to look at third party libraries such as iTextSharp and see if they support that functionality.
-
Jul 10th, 2012, 11:58 AM
#5
Thread Starter
Addicted Member
Re: show multiple Crystal Report
ok. will definitely have a look at it. Thank you so much again for ur reply. Btw I am struggling with another issue. This is the link to it http://www.vbforums.com/showthread.php?t=683803. I hope you can advise on this if you have some free time. Thanks to reply.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|