I found it interesting so worked on it.
fill it with your report paths and see the result...
its working here..lemme know
Imports CrystalDecisions
Public Class Form1
'assuming you have three reports medical,science and chemistry
Private mediflag As Boolean = False
Private sciflag As Boolean = False
Private chemflag As Boolean = False
Private Sub create_tab(name As String) ' this is for creting new tabs
TabControl1.TabPages.Add(name, name)
TabControl1.SelectedIndex = (Convert.ToInt16(TabControl1.TabPages.Count - 1))
'placing report viewer in the selected tab and setting repoert viewer properties
Dim repoertviewer As New Windows.Forms.CrystalReportViewer
repoertviewer.ShowGroupTreeButton = False
repoertviewer.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(repoertviewer)
Select Case name 'placing report viewer in thetab
Case "Medical Report"
'repoertviewer.ReportSource= report path here
Case "Science Report"
'repoertviewer.ReportSource= report path here
Case "Chemistry Report"
'repoertviewer.ReportSource= report path here
End Select
End Sub
Private Sub place_report_viewer()
End Sub
'this is for closeing active tab/report
Private Sub close_report_Click(sender As System.Object, e As System.EventArgs) Handles Btn_close_report.Click
If TabControl1.TabPages.Count <> 0 Then
Dim tabname As String = TabControl1.SelectedTab.Name.ToString
Select Case tabname
Case "Medical Report"
mediflag = False
Case "Science Report"
sciflag = False
Case "Chemistry Report"
chemflag = False
End Select
TabControl1.TabPages.Remove(TabControl1.SelectedTab)
End If
End Sub
Private Sub focus_tab(name As String) ' this will switch to the tab if it exists already
TabControl1.SelectTab(name)
End Sub
Private Sub btn_medical_click(sender As System.Object, e As System.EventArgs) Handles btn_medical.Click
'opening medical tab
If Not mediflag Then
create_tab("Medical Report")
mediflag = True
Else
focus_tab("Medical Report") ' tab already existes...switching to tab
End If
End Sub
Private Sub btn_science_Click(sender As System.Object, e As System.EventArgs) Handles btn_science.Click
'opening science tab
If Not sciflag Then
create_tab("Science Report")
sciflag = True
Else
focus_tab("Science Report") ' tab already existes...switching to tab
End If
End Sub
Private Sub btn_chemistry_Click(sender As System.Object, e As System.EventArgs) Handles btn_chemistry.Click
'opening chemistry tab
If Not chemflag Then
create_tab("Chemistry Report")
chemflag = True
Else
focus_tab("Chemistry Report") ' tab already existes...switching to tab
End If
End Sub
End Class bilal_fazlani
Junior Poster in Training
55 posts since Oct 2011
Reputation Points: 10
Solved Threads: 3