Hi,
You can set group section CanShrink property to false.
But it will work only if you are hiding the controls at the Format procedure, then it will automaticlly shrinks the group.
But it will not work if the controls are hidden at BeforePrint procedure.
In the BeforePrint procedure we can hide the controls, but we cannot hide group section respectively.
Also we can get the summarized value at the BeforePrint procedure, Format procedure always return first item value.
Now we are caught up in tricky situation.
But anyway there is a way to accomplish it but its slightly complex.
I try to explain the complex stuff hopefully you will understand -
Designer Side Changes -
Create a new blank report
Include two Group Headers and Group Footers
GroupHeader1 set DataField property to dtr:Zone
GroupHeader2 set DataField property to dtr:Zone
For the
GroupHeader2 section set CanShrink property to true and
include a bound field textbox into GroupHeader2 section
Name - txtValue
DataField - dtr:InstallationPrice
SummaryGroup to "
GroupHeader2"
SummaryType - SubTotal
Visible - False
In the
GroupFooter1 section include two bound textbox controls one to display Zone and one to display price value.
for Name textbox
Set DataField property to dtr:Zone
for Price textbox set the following properties
DataField - dtr:InstallationPrice
OutputFormat - C
SummaryGroup to "
GroupHeader1"
SummaryType - SubTotal
Script Side Changes -
In the BeforePrint procedure of GroupHeader2 include the below code
|
Code:
|
Sub GroupHeader2_BeforePrint
Dim value As Decimal = Decimal.Parse(ReportUtilities.ReturnTextBoxValue(rpt,"GroupHeader2","txtValue"))
rpt.Sections("GroupFooter1").Visible = value > 0
End Sub |
This will acheive what you want.
Hope it helps.