4
votes

How to remove or hide the main tab section in Crystal Report Viewer (C#).

7
Why removing Hi and Thanks??? :-) - Mark
is this Windows Forms Report Viewer or ASPNET Report Viewer? - Emanuele Greco

7 Answers

8
votes

Omid's answer is correct, but you have to make sure to do that stuff after you have set the viewer's ReportSource. The version in my function below is a little more robust, and makes what's going on a little clearer, though I'm still not sure why doing that bit of magic to the TabControl's ItemSize and SizeMode make the tab bar go away.

// This is a method of a Form with one of these:
//     CrystalDecisions.Windows.Forms.CrystalReportViewer
// This hides the tab control with the "Main Report" button.
public void hideTheTabControl()
{
    System.Diagnostics.Debug.Assert(
        crystalReportViewer1.ReportSource != null, 
        "you have to set the ReportSource first");

    foreach (Control c1 in crystalReportViewer1.Controls)
    {
        if (c1 is CrystalDecisions.Windows.Forms.PageView)
        {
            PageView pv = (PageView)c1;
            foreach (Control c2 in pv.Controls)
            {
                if (c2 is TabControl)
                {
                    TabControl tc = (TabControl)c2;
                    tc.ItemSize = new Size(0, 1);
                    tc.SizeMode = TabSizeMode.Fixed;
                }
            }
        }
    }
}
3
votes

Thanks.

In VB it should seem like this:

    For Each c1 As Control In CrystalReportViewer1.Controls
        If c1.GetType Is GetType(CrystalDecisions.Windows.Forms.PageView) Then
            Dim pv As CrystalDecisions.Windows.Forms.PageView = c1
            For Each c2 As Control In pv.Controls
                If c2.GetType Is GetType(TabControl) Then
                    Dim tc As TabControl = c2
                    tc.ItemSize = New Size(0, 1)
                    tc.SizeMode = TabSizeMode.Fixed
                End If
            Next
        End If
    Next
1
votes

Solution for CrystalDecisions.Web ReportViewer

Put a reference to jquery.js in the page and paste this script:

<script type="text/javascript">
$(document).ready(function () {
    $(".hideableFrame").hide();
});

Explanation

I found that "Main Tab" is placed inside a <tr> with class="hideableFrame"

<tr class="hideableFrame" valign="bottom" height="28" style="display: table-row;">
 <td>
   <img width="5" height="5" 
    ...

I could not work in a css file, since style:display is written on the element, so I wrote a script that changes the visibility to items marked as hideableFrame.

Note: there are 4 -USELESS- elements with class="hideableFrame"; this script will hide all of them.

1
votes

I tried the solution of Emanuele Greco and it works but sometimes it isn't possible to add a reference in your code to jquery. Try this in your web page

<CR:CrystalReportViewer ID="CrystalReportViewer1" 
                runat="server"
                CssClass="Report"
                 HasCrystalLogo="False" 
                 HasSearchButton="False"
                  HasToggleGroupTreeButton="False" 
                   HasZoomFactorList="False" 
                  Height="100%" Width="100%" 
                  meta:resourcekey="CrystalReportViewer1Resource1"
                  EnableDrillDown="False" 
                  ReuseParameterValuesOnRefresh="True" 
                  EnableToolTips="False" ToolPanelView="None" HasDrilldownTabs="False" 
                    HasDrillUpButton="False" /> 
0
votes
            foreach (Control control in crystalReportViewer1.Controls)
            {

                if (control is CrystalDecisions.Windows.Forms.PageView)
                {

                    TabControl tab = (TabControl)(CrystalDecisions.Windows.Forms.PageView)control).Controls[0];

                    tab.ItemSize = new Size(0, 1);

                    tab.SizeMode = TabSizeMode.Fixed;

                    tab.Appearance = TabAppearance.Buttons;

                }

            }
0
votes

set HasDrilldownTabs="false" in CrystalReportViewer control

-1
votes

crystalReportViewer1.DisplayStatusBar = false;