C# 如何删除Crystal Report Viewer中的主选项卡?

C# 如何删除Crystal Report Viewer中的主选项卡?,c#,crystal-reports,C#,Crystal Reports,如何删除或隐藏Crystal Report Viewer(C#)中的主选项卡部分。Crystal ReportViewer1.DisplayStatusBar=false Omid的答案是正确的,但您必须确保在设置查看器的ReportSource后执行该操作。下面我的函数中的版本更加健壮,并且使发生的事情更加清晰,尽管我仍然不确定为什么对TabControl的ItemSize和SizeMode执行这一魔法会使选项卡栏消失 // This is a method of a Form with on

如何删除或隐藏Crystal Report Viewer(C#)中的主选项卡部分。

Crystal ReportViewer1.DisplayStatusBar=false

Omid的答案是正确的,但您必须确保在设置查看器的ReportSource后执行该操作。下面我的函数中的版本更加健壮,并且使发生的事情更加清晰,尽管我仍然不确定为什么对TabControl的ItemSize和SizeMode执行这一魔法会使选项卡栏消失

// 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;
                }
            }
        }
    }
}
谢谢

在VB中,应该是这样的:

    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
CrystalDecisions.Web ReportViewer的解决方案 在页面中放置对
jquery.js
的引用并粘贴此脚本:

<script type="text/javascript">
$(document).ready(function () {
    $(".hideableFrame").hide();
});
我无法在
css
文件中工作,因为
style:display
写在元素上,所以我编写了一个脚本,更改标记为
hideableFrame
的项目的可见性


注意:有4个无用元素带有
class=“hideableFrame”
;此脚本将隐藏所有这些内容。

我尝试了Emanuele Greco的解决方案,效果很好,但有时无法在代码中向jquery添加引用。 在你的网页上试试这个

<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" /> 


在CrystalReportViewer控件中设置HasDrilldownTabs=“false”

为什么要删除Hi和Thank??:-)这是Windows窗体报表查看器还是ASPNET报表查看器?不使用JQuery开发web应用程序非常困难,原因有很多,不仅仅是隐藏主选项卡。无论如何,在这种情况下,我使用Jeff Roe解决方案
<tr class="hideableFrame" valign="bottom" height="28" style="display: table-row;">
 <td>
   <img width="5" height="5" 
    ...
<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" />