【发布时间】:2010-10-08 09:01:36
【问题描述】:
如何在 Crystal Report Viewer (C#) 中删除或隐藏主选项卡部分。
【问题讨论】:
-
为什么要删除你好和谢谢??? :-)
-
这是 Windows 窗体报表查看器还是 ASPNET 报表查看器?
标签: c# crystal-reports
如何在 Crystal Report Viewer (C#) 中删除或隐藏主选项卡部分。
【问题讨论】:
标签: c# crystal-reports
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
【讨论】:
在页面中引用jquery.js并粘贴此脚本:
<script type="text/javascript">
$(document).ready(function () {
$(".hideableFrame").hide();
});
我发现 "Main Tab" 放在 <tr> 和 class="hideableFrame" 内
<tr class="hideableFrame" valign="bottom" height="28" style="display: table-row;">
<td>
<img width="5" height="5"
...
我无法在css 文件中工作,因为style:display 写在元素上,所以我编写了一个脚本来更改标记为hideableFrame 的项目的可见性。
注意:class="hideableFrame" 有 4 个 -USELESS- 元素;此脚本将隐藏所有这些。
【讨论】:
我尝试了 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" />
【讨论】:
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;
}
}
【讨论】:
在 CrystalReportViewer 控件中设置 HasDrilldownTabs="false"
【讨论】:
crystalReportViewer1.DisplayStatusBar = false;
【讨论】: