Customize Crystal Reports
VB Code:
Dim tableStyle1 As New DataGridTableStyle ' DataGridTableStyle
tableStyle1.MappingName = "Stock"
Me.dbgMain.TableStyles.Clear()
Me.dbgMain.TableStyles.Add(tableStyle1)
Me.dbgMain.TableStyles("Stock").GridColumnStyles("ID").Width = 0
Hi All
I Use the above .net code to hide certain columns on the datagrid which enable me to hide or display certain columns according to the users choice.
I am looking for an similar way to achieve the same in Crystal. In other words to give the user a facility to hide or show certain columns or even to resize certain fields.
How do I go about doing this in crystal?
Re: Customize Crystal Reports
VB Code:
Option Strict On
Option Explicit On
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
VB Code:
Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
Dim crTableLogOnInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo
Dim crReportDocument As New CrystalReport1
crConnectionInfo = New ConnectionInfo
With crConnectionInfo
.ServerName = "YourServer
.DatabaseName = "YourDB"
.UserID = "YourUsername"
.Password = "YourPassword"
End With
crDatabase = crReportDocument.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
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 = "Text8" Then
crtextobject.Text = "Lista Condensada de Componentes para Electrificação da Encomenda" '' change text of a textbox
End If
End If
If TypeOf (crreportobject) Is CrystalDecisions.CrystalReports.Engine.FieldObject Then
Dim field As CrystalDecisions.CrystalReports.Engine.FieldObject = DirectCast(crreportobject, CrystalDecisions.CrystalReports.Engine.FieldObject)
If field.Name.TrimEnd = "Field1" Then
field.Width = 100 '' this doesnt work???
field.ObjectFormat.EnableSuppress = True '' hide field
End If
End If
Next
Me.CrystalReportViewer1.DisplayGroupTree = False
Me.CrystalReportViewer1.Zoom(100)
Me.CrystalReportViewer1.ReportSource = crReportDocument
Regards
Jorge