Solved

Added Tab Page programatically to Crystal Report Viewer

Posted on 2004-09-24
4
1,896 Views
Last Modified: 2012-06-22
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!



0
Comment
Question by:bboo
  • 2
4 Comments
 
LVL 42

Expert Comment

by:frodoman
ID: 12144235
Can you explain a little bit more detail what you're trying to do?

0
 
LVL 100

Expert Comment

by:mlmcc
ID: 12144655
0
 

Author Comment

by:bboo
ID: 12145152
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!
0
 
LVL 42

Accepted Solution

by:
frodoman earned 500 total points
ID: 12145563
That's what I thought but I wanted to make sure.  Unfortunately you can't do that - that would require modifying the code of the CRViewer control itself which is a proprietary component.

What you can do is to use a normal tabstrip control in vb.net and have a single viewer (obviously outside of the tabstrip) and then when the tab is changed you simply change the reportsource of the viewer.  Alternatively you can put a different viewer control inside each tab on the vb.net tabstrip and have each control pointed to a different report.

The tab you see that says "MainReport" is an internal working of the viewer control.  If you for example have an on-demand subreport and you drill into it then you'll see two tabs - MainReport and SubReport1.  You can then use these tabs to navigate between the main and sub report(s).  

Since the answer to question #1 is that you can't do it, it makes question #2 irrelevant.  Obviously if you go with one of the alternatives above then you simply show a different viewer or update the viewer to point to a different report -- it's not a matter of directing a dataset to a specific tab.

HTH

frodoman
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now