Link to home
Start Free TrialLog in
Avatar of bboo
bboo

asked on

Added Tab Page programatically to Crystal Report Viewer

I have the following function that changes my crystal reports default 'MainReport' to 'XYZ' text. What I cannot figure out to do is how to add another tab page to the report programatically and then run sql to return the data in that tab page...

In a nutshell, I have:

        Dim rpt As New MyReport
        ' where the ds is a dataset from an sql query
        rpt.SetDataSource(ds.Tables(0))

        CrystalReportViewer.ReportSource = rpt
        SetTabPage()
        CrystalReportViewer.Visible = True


   Private Function SetTabPage() As Boolean

        Dim I As Integer

        Do While I < CrystalReportViewer.Controls.Count
            If TypeOf (CrystalReportViewer.Controls(I)) Is CrystalDecisions.Windows.Forms.PageView Then
                Dim J As Integer
                Do While J < CrystalReportViewer.Controls.Count
                    If CType(CrystalReportViewer.Controls(I).Controls(J), System.Windows.Forms.TabControl).TabPages.Count > 0 Then
                        CType(CrystalReportViewer.Controls(I).Controls(J), System.Windows.Forms.TabControl).TabPages.Item(0).Text = "XYZ"
                        'CType(CrystalReportViewer.Controls(I).Controls(J), System.Windows.Forms.TabControl).TabPages.Add(???????????)
                        Exit Do
                    End If
                Loop
                Exit Do
            Else
                CrystalReportViewer.Controls(I).Visible = False
            End If
        Loop
    End Function


******** The spot with the ?????? is where I would like the TabPage added ****

The second piece is the how do I direct the dataset to a tab page on the Crystal report ...

Thanks!



Avatar of frodoman
frodoman
Flag of United States of America image

Can you explain a little bit more detail what you're trying to do?

Avatar of Mike McCracken
Mike McCracken

Avatar of bboo

ASKER

The link sent by mlmcc is not for VB .NET .. I am using Crystal Descisions 9. plus I am not using the CRViewer. I am using CrystalReportViewer.


For frodoman:
I am trying to add a tab to CrystalReportViewer that is on a form. The CrystalReportViewer has a default tab called 'MainReport'. I have found how to change to Tab Text for MainReport to 'XYZ' as you can see in my question. The report displays data from a dataset. This all works fine.

1) I would like to be able to add another tab to the CrystalReportViewer.

After I know how to do this ...

2) I would like to know how to direct dataset1 to the first tab and dataset2 to the second tab.

This is a VB .NET application.
Thanks!
ASKER CERTIFIED SOLUTION
Avatar of frodoman
frodoman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial