Fixed Price Projects          Flexibele IT oplossingen

Software op maat              Web Applications

To set the width of the group tree in a crystal report you can use this function.

It seeks out the group control in the crystalviewer control and changes it's ratio.

After doing this the user can change the width manually.  (otherwise it is fixed)


    ''' <summary>

    ''' Set the width of a Crystal Reports Viewer Group Tree

    ''' </summary>

    ''' <param name="crystalReportViewer">crystalreports viewer object</param>

    ''' <param name="ratio">optional ratio to use</param>

    ''' <param name="initialShowTree">show the tree at startup</param>

    ''' <remarks></remarks>

    Public Shared Sub setWidthGroupTree(ByRef crystalReportViewer As CrystalDecisions.Windows.Forms.CrystalReportViewer, Optional ratio As Integer = 2, Optional initialShowTree As Boolean = False)


            For Each c As Control In crystalReportViewer.Controls

                If c.GetType Is GetType(CrystalDecisions.Windows.Forms.ReportGroupTree) Then

                    Dim rt As CrystalDecisions.Windows.Forms.ReportGroupTree = DirectCast(c, CrystalDecisions.Windows.Forms.ReportGroupTree)

                    rt.Scale(New Drawing.SizeF(ratio, 1))

                    Exit For

                End If


            crystalReportViewer.DisplayGroupTree = initialShowTree

        Catch ex As Exception

            Throw New Exception("Exception on setWidthGroupTree: " & ex.Message)

        End Try

    End Sub

Categorie: Crystal Reports
Actions: E-mail | Permalink |