Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Added Tab Page programatically to Crystal Report Viewer

Posted on 2004-09-24
4
Medium Priority
?
1,970 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
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 my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

722 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