Change control height in before print

Stimulsoft Reports.WEB discussion
nemanja.avramovic
Posts: 17
Joined: Wed Jul 11, 2012 11:41 am

Change control height in before print

Post by nemanja.avramovic »

Hi,
I need simple functionality to change child control's height to fit in parents control height on before print event when using dataBand.
Adjacent columns may expand height of row, but all columns should have the same height.
Let's observe component Panel which contains TextBox within it.
Using behaviour Grow to height is doing the job when I have the table of data, and everything is on the single page.

The problem is when I have Subreport, so controls within Subreport are on the other page, so Grow to height doesn't work for controls within Subreport.
Hierarchy is something like:
MainPage -> DataBand -> Panel1WithBorders -> Subreport1
Subreport_Page -> DataBand -> Panel2WithBorders -> TextBoxContent
I need Panel2WithBorders to expand its height to Panel1WithBorders somehow in order to achieve esthetical presentation.

What is logic, is to implement before print event in Panel within Subreport to expand height of Panel2WithBorders.
Panel2WithBorders.Height = Panel1WithBorders.Height;
But it doesn't work. Perhaps this property refers only to static value initially set. Is there a way to obtain an actual value calculated during data row generation, and to set it manually?
Are there any better solutions or work around?

Problem is illustrated with image in attachment.

I would be very greateful,
Best regards!
Attachments
Illustration of problem.
Illustration of problem.
grow height stimulsoft.PNG (14.48 KiB) Viewed 6480 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Change control height in before print

Post by HighAley »

Hello.

We couldn't reproduce your issue.
Please, send us your report template with data to reproduce the issue for analysis.

Thank you.
nemanja.avramovic
Posts: 17
Joined: Wed Jul 11, 2012 11:41 am

Re: Change control height in before print

Post by nemanja.avramovic »

Oh, thank you for your concern.
Maybe my explanation was not so clear. This should be simple to reproduce.

Here is a report sample in attachment. My comments are in generated text, and those Text controls that contain comments are configured according to comment meaning.
Version that is used is <ReportVersion>2012.3.1500</ReportVersion> as it stands in .mrt file.

The goal of this task is to have right-borders from controls within Subreport with height to fit main dataBand row height dynamically.
Hope, you could help. If there is something still that is not clear, please, tell me.

Best regards!
Attachments
FixHeightInSubreport.mrt
(11.27 KiB) Downloaded 615 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Change control height in before print

Post by HighAley »

Hello.

The easiest way is to use primitives.
Please look at the attached report template.
FixHeightInSubreport.mrt
(17.74 KiB) Downloaded 651 times
Thank you.
nemanja.avramovic
Posts: 17
Joined: Wed Jul 11, 2012 11:41 am

Re: Change control height in before print

Post by nemanja.avramovic »

Thank you for showing this technic. I spent some time for analysis.
Unfortunately, the solution is not proper for our needs.

When we have column headers, and much data to render with content that breaks through pages, these verticalLinePrimitives do not break as expected.
The bad thing is that VerticalLinePrimitive is not declared per every dataRow to fill cell from top to bottom of each dataRow, but to generate once from one band to another. I was trying combinations of different bands, and concluded that connection is possible only among one of DataBand, HeaderBand, FooterBand.

I tried to attach it to headerBand and footerBand, but then vertical line goes through repeating headers on every page (see image: VerticalLinePrimitive - goes through repeating headers.png)
Also, dataRow from dataBand may break accordingly of it's content, but vertical line goes more further to the bottom of page (see image: VerticalLinePrimitive - break to the bottom of page (not to the bottom of dataRow).png).

More problems occur when I want to use CrossBand to generate dynamically resolved number of columns in subreport. Solution with VerticalLinePrimitive is available in that case, but it is very hard, because I have to have a pool with statically predefined number of VerticalLinePrimitives and to calculate their positions on before print. I actually tried this, and it works. But, it is not good solution. Very difficult to implement and maintain, and there are drawbacks I described and illustrated in images.

More elegant and general way would be one of the solutions I suggested.
1) To process control height in before print somehow, if calculated referent height is available.
2) Or to make some connection between controls and let it calculate internally, like GrowToHeight property does.
I haven't found the way to use any of them and I was hoping that some of these are supported.

Please tell me if you have more ideas.
Best regards!
Attachments
VerticalLinePrimitive - goes through repeating headers.PNG
VerticalLinePrimitive - goes through repeating headers.PNG (16.81 KiB) Viewed 6432 times
nemanja.avramovic
Posts: 17
Joined: Wed Jul 11, 2012 11:41 am

Re: Change control height in before print

Post by nemanja.avramovic »

Another attachment...
Attachments
VerticalLinePrimitive - break to the bottom of page (not to the bottom of dataRow).PNG
VerticalLinePrimitive - break to the bottom of page (not to the bottom of dataRow).PNG (13.6 KiB) Viewed 6432 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Change control height in before print

Post by HighAley »

Hello.

In this case there is another solution for your problem.
It's hard to calculate the height of the Band in the Sub-report so it could be done some code.
Please, learn the attached report template.
FixHeightInSubreport 2.mrt
(11.79 KiB) Downloaded 665 times
We added two variables in your report and code in the Get Tag event of the DataBand1, Get Value event of the TextBoxBP and After Print event of the Page1.

Thank you.
nemanja.avramovic
Posts: 17
Joined: Wed Jul 11, 2012 11:41 am

Re: Change control height in before print

Post by nemanja.avramovic »

Sir,
I am very grateful for this solution. It has improved my knowledge in Stimulsoft reporting.
I don't understand how actually works AfterPrint and why it works. I supposed that after print, all printing dimensions are calculated and cannot be changed.
I declared string variable logMessage and tried to change it's value on After Print, and I had put it on the Text control to preview like {logMessage}, but value is not updated.
I don't understand how height can be updated in AfterPrint.
It would be precious if you can explain or refer me where I can read about it in more details.

Unfortunately, this kind of solution works only when I have static report with only one row.
I tried this solution on my concrete report with dataSource, and it just ignores every height that I set in AfterPrintEvent for control in DataBand. (Probably data binding overrides or prevents it)
I don't see the way to set height for each Text control per row as AfterPrint event occurs only once.

Best regards!
nemanja.avramovic
Posts: 17
Joined: Wed Jul 11, 2012 11:41 am

Re: Change control height in before print

Post by nemanja.avramovic »

Hello,
I had another idea of solution. Unfotunately unsuccessful, but it might be useful to share with you.

I configured next.
Text controls within Subreport have very large height, enough to fill height of cell with borders even when cell height is over whole page.
Panel that holds Subreport has GrowToHeight=true to synchronize with other columns in row, but CanGrow=false in order to prevent growth because of Text control large height within Subreport.
This is fine if we know that content of Subreport never has content that requires more height than other columns from same row. In my case, Subreport column needs only one line, so it is fine.

This solution would be great if Panel that holds Subreport truncated content within it that has larger height than Panel itself.
Cropping of container content was something that was expected, but unfortunately not achieved. Borders exceeded cells and went even to the bottom of page (Illustrated on attached image).

I don't understand how this actually works, because content in Subreport partially behaves like independent (without parent), and partially dependent.
When I set CanGrow=true to Panel that holds Subreport, it grows according to content in Subreport, behaving like a parent.
I was wondering how difficult is for you to implement property for Panel (and other container controls) CanTruncate that would work for Subreport relations?

Please, tell me your impressions about this.
Best regards!
Attachments
grow height stimulsoft - Content not truncated.PNG
grow height stimulsoft - Content not truncated.PNG (27.7 KiB) Viewed 6419 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Change control height in before print

Post by HighAley »

Hello.

Sorry, but we need more time to prepape an answer for you.

Thank you.
Post Reply