|
-
Feb 5th, 2007, 06:10 PM
#1
Thread Starter
PowerPoster
Controlling report results thru VB.Net???
Does anyone have a good example of using CR in .Net? I'm new to .Net in general and this version of CR. I was never really great at writing CR reports. I'm curious as to how much of the report can be controlled thru VB code.
Thanks,
-
Feb 6th, 2007, 12:53 PM
#2
Re: Controlling report results thru VB.Net???
VB Code:
Option Explicit On
Option Strict On
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
Dim crTableLogOnInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo
Me.CrystalReportViewer1.Width = Me.Width - 30
Me.CrystalReportViewer1.Height = Me.Height - 50
Dim crReportDocument As New CrystalReport1
crConnectionInfo = New ConnectionInfo
With crConnectionInfo
.ServerName = "Dinefer"
.DatabaseName = "Dinefer"
.UserID = "Utilizador"
.Password = "ab,cdef123!"
End With
crDatabase = crReportDocument.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
formula = "{auxprintcorpoenc.login}='" & Utilizador.Login & "'"
crReportDocument.RecordSelectionFormula = formula
crReportDocument.PrintOptions.PaperOrientation = PaperOrientation.Landscape
crReportDocument.PrintOptions.PaperSize = PaperSize.PaperA4
CrystalReportViewer1.DisplayGroupTree = False
CrystalReportViewer1.Zoom(100)
''crReportDocument.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
''crReportDocument.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
''crReportDocument.Export()
''CrystalReportViewer1.ExportReport()
CrystalReportViewer1.ReportSource = crReportDocument
"The dark side clouds everything. Impossible to see the future is."
-
Feb 6th, 2007, 01:29 PM
#3
Thread Starter
PowerPoster
Re: Controlling report results thru VB.Net???
-
Feb 7th, 2007, 02:04 PM
#4
Thread Starter
PowerPoster
Re: Controlling report results thru VB.Net???
Was also wondering if it's possible to use VB code to access each Control on a CR Report, ie; labels, textboxes, etc.
-
Feb 7th, 2007, 02:45 PM
#5
Thread Starter
PowerPoster
Re: Controlling report results thru VB.Net???
I'm trying to use the code in Post #2 on a new Form with a CR Viewer control placed on the form. When I try to insert the statement:
VB Code:
Dim crReportDocument as New CrystalReport1
Intellisense doesn't prompt me for CrystalReport1. I've copied the sample as you have it upto the point where I insert the above Dim statement.
What am I missing?
Thanks,
-
Feb 7th, 2007, 06:07 PM
#6
Re: Controlling report results thru VB.Net???
 Originally Posted by blakemckenna
I'm trying to use the code in Post #2 on a new Form with a CR Viewer control placed on the form. When I try to insert the statement:
VB Code:
Dim crReportDocument as New CrystalReport1
Intellisense doesn't prompt me for CrystalReport1. I've copied the sample as you have it upto the point where I insert the above Dim statement.
What am I missing?
Thanks,
You need to replace CrystalReport1 with the name of report you have created.
"The dark side clouds everything. Impossible to see the future is."
-
Feb 7th, 2007, 06:16 PM
#7
Thread Starter
PowerPoster
Re: Controlling report results thru VB.Net???
got it...Thanks! One more thing....can I control the entire report thru VB.Net. In other words, all the controls that I have on my report, ie; textboxes, labels, etc. Can I pass them values via my VB Code?
-
Feb 8th, 2007, 04:23 AM
#8
Re: Controlling report results thru VB.Net???
This is how i change the text of 2 textboxes on the report, called text3 and text5.
VB Code:
Dim crreportobject As CrystalDecisions.CrystalReports.Engine.ReportObject
For Each crreportobject In crReportDocument.ReportDefinition.ReportObjects
If TypeOf (crreportobject) Is CrystalDecisions.CrystalReports.Engine.TextObject Then
Dim crtextobject As CrystalDecisions.CrystalReports.Engine.TextObject = DirectCast(crreportobject, CrystalDecisions.CrystalReports.Engine.TextObject)
If crreportobject.Name.TrimEnd = "Text3" Then
crtextobject.Text = "TEXT"
End If
If crreportobject.Name.TrimEnd = "Text5" Then
crtextobject.Text = "TEXT"
End If
End If
Next
"The dark side clouds everything. Impossible to see the future is."
-
Feb 8th, 2007, 11:51 AM
#9
Thread Starter
PowerPoster
Re: Controlling report results thru VB.Net???
that's what I'm lookin' for....Thanks Asgorath!
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
|