Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Added Tab Page programatically to Crystal Report Viewer

Posted on 2004-09-24
4
Medium Priority
?
1,988 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 101

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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline

783 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