Thanks a lot, Armin.
I'll try this and let you know.
Bill
"Armin Zingler" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
> "Bill Nguyen" <(E-Mail Removed)> schrieb im Newsbeitrag
> news:(E-Mail Removed)...
> > Armin;
> > Thanks for the tip.
> > I used ReportDocument and it worked. However, there are some problems
> > associated with this:
> >
> > You have to treat each report differently depending on the number of
> > sections you have in it. There is no universal section name/label that
you
> > can use. For example, I have 1 report with 7 sections, another with 9 (I
> use
> > sections.count to display the sections). The section count includes
> > suppressed and non-suppressed sections. The .Sections(x), however, only
> > counts non-suppressed sections.
>
> I can't repro this. The Sections property contains all sections, no matter
> if suppressed or not. I used the following code:
>
> Dim rpt As New CrystalReport2
> Dim sec As CrystalDecisions.CrystalReports.Engine.Section
>
> Debug.WriteLine("Before suppressing detail section:")
> Debug.WriteLine(rpt.ReportDefinition.Sections.Count())
>
> For Each sec In rpt.ReportDefinition.Sections
> Debug.WriteLine(sec.Name)
> Next
>
> rpt.detail.SectionFormat.EnableSuppress = True
>
> Debug.WriteLine("After suppressing detail section:")
> Debug.WriteLine(rpt.ReportDefinition.Sections.Count())
>
> For Each sec In rpt.ReportDefinition.Sections
> Debug.WriteLine(sec.Name)
> Next
>
>
> Output:
>
> Before suppressing detail section:
> 5
> Section1
> Section2
> detail
> Section4
> Section5
> After suppressing detail section:
> 5
> Section1
> Section2
> detail
> Section4
> Section5
>
>
> > I don't know of any way to get section
> > name/label so that I can just use the following code:
> >
> >
>
reportDocument1.ReportDefinition.Sections("SECTION_NAME").SectionFormat.Enab
> > leSuppress = True
>
> This works for me:
> rpt.ReportDefinition.Sections("detail").SectionFormat.EnableSuppress =
True
>
>
> > If this is possible, I can just label the section following a naming
> > convention for all of my reports and the code will work for all of them.
>
> I'm not a fan of "late binding". Means, if one of your report (mistakenly)
> has a different name, or you wrote the wrong section name in your code,
the
> compiler can't find this error, whereas using the typed reference using
> "report.detail." can be checked at compile time. But that's up to you, I
can
> only say that the code above worked for me.
>
> --
> Armin
>
|