Results 1 to 2 of 2

Thread: Customize Crystal Reports

  1. #1

    Thread Starter
    Addicted Member SkyCoder's Avatar
    Join Date
    Oct 2003
    Location
    Moon Crater 25
    Posts
    183

    Customize Crystal Reports

    VB Code:
    1. Dim tableStyle1 As New DataGridTableStyle ' DataGridTableStyle
    2.  tableStyle1.MappingName = "Stock"
    3.  Me.dbgMain.TableStyles.Clear()
    4.  Me.dbgMain.TableStyles.Add(tableStyle1)
    5.  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?

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: Customize Crystal Reports

    VB Code:
    1. Option Strict On
    2. Option Explicit On
    3.  
    4. Imports CrystalDecisions.CrystalReports.Engine
    5. Imports CrystalDecisions.Shared

    VB Code:
    1. Dim crDatabase As Database
    2.                     Dim crTables As Tables
    3.                     Dim crTable As Table
    4.                     Dim crTableLogOnInfo As TableLogOnInfo
    5.                     Dim crConnectionInfo As ConnectionInfo
    6.                     Dim crReportDocument As New CrystalReport1
    7.                     crConnectionInfo = New ConnectionInfo
    8.                     With crConnectionInfo
    9.                         .ServerName = "YourServer
    10.                         .DatabaseName = "YourDB"
    11.                         .UserID = "YourUsername"
    12.                         .Password = "YourPassword"
    13.                     End With
    14.                     crDatabase = crReportDocument.Database
    15.                     crTables = crDatabase.Tables
    16.                     For Each crTable In crTables
    17.                         crTableLogOnInfo = crTable.LogOnInfo
    18.                         crTableLogOnInfo.ConnectionInfo = crConnectionInfo
    19.                         crTable.ApplyLogOnInfo(crTableLogOnInfo)
    20.                     Next
    21.  
    22.                     Dim crreportobject As CrystalDecisions.CrystalReports.Engine.ReportObject
    23.                     For Each crreportobject In crReportDocument.ReportDefinition.ReportObjects
    24.                         If TypeOf (crreportobject) Is CrystalDecisions.CrystalReports.Engine.TextObject Then
    25.                             Dim crtextobject As CrystalDecisions.CrystalReports.Engine.TextObject = DirectCast(crreportobject, CrystalDecisions.CrystalReports.Engine.TextObject)
    26.                             If crreportobject.Name.TrimEnd = "Text8" Then
    27.                                 crtextobject.Text = "Lista Condensada de Componentes para Electrificação da Encomenda" '' change text of a textbox
    28.                             End If
    29.                         End If
    30.                         If TypeOf (crreportobject) Is CrystalDecisions.CrystalReports.Engine.FieldObject Then
    31.                             Dim field As CrystalDecisions.CrystalReports.Engine.FieldObject = DirectCast(crreportobject, CrystalDecisions.CrystalReports.Engine.FieldObject)
    32.                             If field.Name.TrimEnd = "Field1" Then
    33.                                 field.Width = 100 '' this doesnt work???
    34.                                 field.ObjectFormat.EnableSuppress = True '' hide field
    35.                             End If
    36.                         End If
    37.                     Next
    38.                     Me.CrystalReportViewer1.DisplayGroupTree = False
    39.                     Me.CrystalReportViewer1.Zoom(100)
    40.                     Me.CrystalReportViewer1.ReportSource = crReportDocument

    Regards
    Jorge
    Last edited by Asgorath; Oct 18th, 2005 at 05:20 AM.
    "The dark side clouds everything. Impossible to see the future is."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width