|
-
Apr 22nd, 2003, 12:21 AM
#1
Thread Starter
Addicted Member
VB.Net / Crystal reps - one display form
I have one display form to display my Crystal Rpeorts for my VB.NET app called CRDisplay.vb. I want to use this one form to display any number of reports I have set up such as CRMembers.rpt or CRStudents.rpt etc but I don't know how to pass this as a parameter to the CRDisplay form.
if i hard code the report name as in the code below it works fine (naturally)
What I want to do is pass the CR Report name to this form from a user report selection form so I only have the one display form rather than a separate display form for each report !! I have tried different ways but can't seem to get the name of the report file into this form
Any help woould be greatly appreciated.
Public Class CRDisplay
Inherits System.Windows.Forms.Form
Dim rpt1 As New CRmembers() 'this works - see below ****
' or dim rpt1 as CRStudents () 'if this is the report I want
#Region " Windows Form Designer generated code "
#End Region
Private Sub CRDisplay_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
CRViewer.ReportSource = rpt1 ' this works - see above ****
End Sub
End Class
-
Apr 22nd, 2003, 01:45 AM
#2
Frenzied Member
From what you have written I think you are going to create a new instance of a crystal reports just by passing its name. This works for me;
VB Code:
Dim rpt As CrystalDecisions.CrystalReports.Engine.ReportDocument
Try
rpt = Activator.CreateInstance(Type.GetType("Namespace.Reportname"))
' Here you pass the name of your report along with the root namespace of it,
'no problem you should have here.
Catch ex As Exception
MessageBox.Show("Error creating: " + ex.ToString())
End Try
'here you can do what ever you want with your report :p
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Apr 22nd, 2003, 02:40 PM
#3
Junior Member
assign it when creating the instance of the new display form:
Dim myreport As New CRmembers()
Dim newform As New CRDisplay ()
newform.CrystalReportViewer1.ReportSource = myreport
newform.Show()
-
Apr 22nd, 2003, 07:28 PM
#4
Thread Starter
Addicted Member
Thankyou
I was missing the point - keep thinking old VB without being able to have multiple instances of the one form - still coming to grips with .NET
thanks again
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
|