Friday, November 13, 2009

How to Display/Hide Crystal Report Viewer Tab and Status Bar at run time using VB.NET

How to Display/Hide Crystal Report Viewer Tab and Status Bar at run time using VB.NET


I am working with Visual Studio 2005 and faced some issues while working with crystal report, my requirement is to display and hide tab and status bar control from crystal report viewer, event tab control should display customized name in the tab text. I found the way to do this, below the code in vb.net

Display/Hide crystal report viewer tab control and rename the tab control


''' <summary>

''' This method will make tab controls visibile True/False

''' </summary>

''' <remarks>Ritesh</remarks>

Private Sub CrystalReportViewerTab(ByVal rptViewer As CrystalDecisions.Windows.Forms.CrystalReportViewer, ByVal isVisible As Boolean)

Dim reportTabs As TabControl = rptViewer.Controls(0).Controls(0)

'if tab visible

If isVisible Then
With reportTabs

.ItemSize = New Size(70, 18)

.SizeMode = TabSizeMode.FillToRight

.Appearance = TabAppearance.Normal

'Here you can give customize name to tab

.TabPages(0).Text = "My Tab Text"

End With

Else 'if tab hide

With reportTabs

.ItemSize = New Size(0, 1)

.SizeMode = TabSizeMode.Fixed

.Appearance = TabAppearance.Buttons

End With

End If

End Sub

Display/Hide crystal report viewer status bar


''' This method will make status bar visibile True/False

Public Sub CrystalReportViewerStatusBar(ByVal rptViewer As CrystalDecisions.Windows.Forms.CrystalReportViewer, ByVal isVisible As Boolean)

Dim ctl As Control

For Each ctl In rptViewer.Controls

If ctl.GetType().Name.ToString() = "StatusBar" Then

ctl.Visible = isVisible

End If

Next

End Sub

1 comment:

Anonymous said...

Thanks... works gr8