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,
Printable View
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,
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
Thanks Asgorath!!!
Was also wondering if it's possible to use VB code to access each Control on a CR Report, ie; labels, textboxes, etc.
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.Quote:
Originally Posted by blakemckenna
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?
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
that's what I'm lookin' for....Thanks Asgorath!