AR3 中页面特定的边距设置
我正在尝试根据页码以编程方式设置活动报表中的边距。
具体来说,第一页需要有较小的边距(以便最上面带有寄信人地址的文本框与公司徽标的对齐方式相匹配),之后的每一页都应具有标准的 2.54 厘米边距。
我读过的帖子表明检测实际页码可能会出现问题,因此我尝试使用 ReportStart 和 PageStart 处理程序以及一些非常简单的逻辑来设置边距。
在报告的代码隐藏中,我添加了两个处理程序和布尔值:
this.ReportStart += UFAnReportStart;
this.PageStart += UFAnPageStart;
bool bFirstPage = true;
然后添加了两个回调,如下所示:
private void UFAnReportStart(object sender, System.EventArgs eArgs)
{
this.PageSettings.Margins.Top = 0.1965278F;
}
private void UFAnPageStart(object sender, System.EventArgs eArgs)
{
// every page after the first should have standard margins.
if (!bFirstPage)
{
this.PageSettings.Margins.Top = 2.54F;
}
bFirstPage = false;
}
这似乎对边距没有任何影响。这种方法完全是错误的吗?或者 PageSettings 对象是报表范围的属性吗?
欢迎任何关于替代方法的建议。
使用 Activereports3,版本 5.2.1013.2。
谢谢你!
I'm trying to programmatically set the margins in an active report based on the page number.
Specifically, the first page needs to have small margins (so that the top-most text box with a return address matches the alignment of a company logo) and every page after that should have standard 2.54cm margins.
I've read posts that suggest that detecting the actual page number can be problematic so I've tried using the ReportStart and PageStart handlers along with some very simple logic to set the margins.
In the code-behind for the report, I added the two handlers and bool value:
this.ReportStart += UFAnReportStart;
this.PageStart += UFAnPageStart;
bool bFirstPage = true;
And then added the two callbacks as follows:
private void UFAnReportStart(object sender, System.EventArgs eArgs)
{
this.PageSettings.Margins.Top = 0.1965278F;
}
private void UFAnPageStart(object sender, System.EventArgs eArgs)
{
// every page after the first should have standard margins.
if (!bFirstPage)
{
this.PageSettings.Margins.Top = 2.54F;
}
bFirstPage = false;
}
This doesn't seem to have any effect on the margins. Is this approach just plain wrong? Or is the PageSettings object a report wide property?
Any suggestions for alternative approaches are welcomed.
using Activereports3, version 5.2.1013.2.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以编程方式,单位为英寸而不是 CM :) 设计时设置仅影响设计器中显示的内容。
以下内容对我有用:
ActiveReports 支持论坛是免费的、活跃的并且由我们的支持团队监控,因此它们是询问有关 ActiveReports 问题的好地方。
希望这有帮助,
Programmatically the units are in inches not CM :) The design-time setting only affects what is shown in the designer.
The following worked for me:
The ActiveReports Support Forums are free, active, and monitored by our support team so they're a great place to ask questions about ActiveReports.
Hope this helps,
事实证明,您建议的方法确实有效!我们将文档呈现为 PDF 和 RTF。在 Adobe Reader 中以 PDF 形式查看时,边距正确,但在 Word 2010 中以 RTF 形式查看时,边距不显示;我没有注意到的事情。
啊,浪费了几个小时! :P
当然,这提出了一个问题:为什么 RTF-in-word 版本中不显示边距……?
As it turns out, the approach you suggested DOES work! We render the document into both PDF and RTF. The margins are correct when viewed as a PDF in Adobe Reader, but don't show when viewd as an RTF in Word 2010; something I had failed to notice.
Ach, hours wasted! :P
This, of course, raises the question of why the margins don't show in the RTF-in-word version..?