Solved

Added Tab Page programatically to Crystal Report Viewer

Posted on 2004-09-24
4
1,881 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

706 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

16 Experts available now in Live!

Get 1:1 Help Now