简体   繁体   English

如何在Reportviewer Visual Studio中修复矩形高度

[英]How to fix rectangle height in Reportviewer Visual Studio

I am working with Visual Studio 2010 ReportViewer WinForms. 我正在使用Visual Studio 2010 ReportViewer WinForms。 I have been unable to figure out how to fix the rectangle height in a report. 我一直无法弄清楚如何在报表中固定矩形高度。 I've tried using a table within the rectangle, also a table in a sub report that is placed in the rectangle of the main report with no success. 我尝试使用矩形内的表格,也将子报表中的表格放置在主报表的矩形中,但没有成功。

Basically, I am setting up an invoice-type report that must keep its' form and should not be allowed to grow so that elements are pushed onto a second page. 基本上,我正在建立一个发票类型的报告,该报告必须保持其格式,并且不允许增长,以便将元素推到第二页上。

Both rectangle and tables will always grow vertically based on the content. 矩形和表格都将始终根据内容垂直增长。 There is no way to really stop this. 没有办法真正阻止这种情况。

There are a couple of properties that might be able to help you get the correct page breaking in place: 有几个属性可以帮助您正确地分页:

  • KeepTogether indicates whether to keep all sections of the data region together on pane page. KeepTogether指示是否在窗格页面上将数据区域的所有部分放在一起。 When set on true and the region is to large to fit the page, this will add a page-break before the start of the region to try and fit as much as possible on a single page. 如果将其设置为true并且该区域要适合页面较大,则会在该区域开始之前添加分页符,以尝试尽可能地适合单个页面。
    So if you wish for the region to start at the initial location but break afterwards, make sure this is to false . 因此,如果您希望该区域从初始位置开始但之后又中断,请确保将其设置为false
  • PageBreak has the parameter BreakLocation which can be used to determine a fixed place to add a page-break. PageBreak具有参数BreakLocation ,可用于确定添加分页BreakLocation的固定位置。 You can set it on Start , End , StartAndEnd or Between . 您可以在StartEndStartAndEnd之间设置它。
    You could split your report in fixed pages and use these to add standard page-breaks in the desired (fixed) locations. 您可以将报告分成固定的页面,并使用它们在所需的(固定的)位置添加标准分页符。

These properties alone might not be enough to get your desired result. 仅这些属性可能不足以获得所需的结果。 Especially when working with tables it is hard to add a page-break after a fixed amount of rows. 特别是在使用表时,很难在固定数量的行之后添加分页符。
It is hard to give you a detailed description of a possible approach with the amount of information you gave me, but here is some general advice. 很难用您提供给我的大量信息来详细描述可能的方法,但是这里有一些一般性建议。

You should split your data in the correct intervals before sending the datasource to the reporter. 在将数据源发送到报告器之前​​,应按正确的时间间隔拆分数据。 You can for example use grouping to place them in the correct intervals and add page-breaks based on the grouping. 例如,您可以使用分组将它们以正确的间隔放置,并根据分组添加分页符。
Another solution is to add them in separate containers, this will require you to have enough spare data regions at your disposal. 另一个解决方案是将它们添加到单独的容器中,这将需要您有足够的备用数据区域供您使用。 If there are too many you can always hide the empty ones based on an expression set for the Hidden property. 如果太多,您总是可以根据为Hidden属性设置的表达式来隐藏空的。

It won't be easy to set this up correctly so that it can dynamically grow. 正确设置它并不容易,以便它可以动态增长。 It takes a lot of puzzling from your end but pretty much any layout should be possible to achieve. 从头到尾都需要很多困惑,但是几乎任何布局都应该可以实现。
I wish I could give you a more specific solution to your problem and am willing to help you further if you give me an example to work with. 希望我能为您的问题提供更具体的解决方案,如果您能给我一个例子,愿意为您提供进一步的帮助。 But ultimately this is something you should be able to achieve on your own. 但是最终,这是您应该能够自己实现的目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM