在VS10中,有没有办法保持SizeToReportContent=true并强制垂直滚动条? 我有一个允许用户选择报表的 DDL,它为报表查看器设置数据源。SizeToReportContent 似乎是动态控制报表宽度以与报表查看器的宽度对齐的唯一方法。 该页包含一个高度小于报表的显示区域。 如果报表查看器具有垂直滚动条,则报表将满足显示区域约束。
我已经尝试了对.rdlc进行样式格式和大小更改的各种组合,但没有在SizeToReportContent=true时强制滚动条。
报表查看器的宽度和高度属性都将被重写,但 .rdlc 的哪个属性将被重写?
报告正在当地处理,但我认为这没有什么不同。
啪!
我希望这对某人有所帮助...
暴力强制报表查看器生成所需的页面尺寸。
设置 SizeToReport=false。 将每个报表的所需宽度追加到用"|"分隔的 .rdlc 值的名称中。 在运行报告方法中,拆分所选值以获取 .rdlc 名称及其宽度。 这意味着从物理上确定每个报告的宽度,以使用报告名称 - [弱!
法典:
报表 .ascx 中的 ddl [实际从数据库填充,但我想显示数据]
<asp:DropDownList ID="reportDropDownList" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RunReport">
<asp:ListItem Selected="True" Value="0">-- Select Report --</asp:ListItem>
<asp:ListItem Value="RVSum.rdlc|504" >RV Purchased Sum</asp:ListItem>
<asp:ListItem Value="ZeroPricePurchasesView.rdlc|550">Zero Price Purchases</asp:ListItem>
...
</asp:DropDownList>
运行报告方法:
protected void RunReport(object sender, EventArgs e)
{
ObjectDataSource source = new ObjectDataSource("WC.DataAccess.DAO.ReportsDAO", "GetAllReports");
string path = "RDLC" + "\";
string ddlValue = "";
if (reportDropDownList.SelectedIndex != 0)
{
ddlValue = reportDropDownList.SelectedValue.ToString();
string[] ddlSplit = ddlValue.Split('|'); //split ddl selected value
path = path + ddlSplit[0]; //.rdlc name
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.ReportPath = path;
reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", source));
reportViewer.AsyncRendering = false;
reportViewer.SizeToReportContent = false;
reportViewer.ShowZoomControl = false;
reportViewer.Height = 400; // default value but exactly what is needed
reportViewer.Width = Convert.ToInt32(ddlSplit[1]); // desired report width
reportViewer.DataBind();
}
else /* default clear viewer */
{
reportDropDownList.SelectedIndex = 0;
reportViewer.LocalReport.DataSources.Clear();
reportViewer.Reset();
}
}
我不喜欢这种类型的编程,但在 MS 提供更好的报告查看器之前,这将可以。
我仍然对一些建议感兴趣 - 现在继续前进...