How to deal with DataCount=0?

Stimulsoft Reports.NET discussion
Post Reply
Jennypi
Posts: 361
Joined: Mon Nov 17, 2008 7:13 am
Location: France

How to deal with DataCount=0?

Post by Jennypi »

Hi all,

In one of my reports, I would like to show as many labels as the number contained in the field "number".
For example, if for row 1 "number" contains 2, 2 labels are printed.
For row 2, "number" contains 0, no labels are printed.
For row 3, "number" contains 5, 5 labels are printed.
It works very well with 2 DataBands (one master DB + one with mastercomponent= the first one) and this BeforePrint event:

Code: Select all

if (plantation.nb_of_fruits==0)
{
DataBand2.CountData=0;
plantation.Next();
DataBand2.CountData=1;
}
else
{DataBand2.CountData=plantation.nb_of_fruits;}
But I have a problem when 2 successive rows have 0 in "number". The first one is ok (no label), but DataCount for the second one is set to 1 because of the code in the event.
How can I do?

Thank you.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How to deal with DataCount=0?

Post by HighAley »

Hello.

Try to use next code:

Code: Select all

DataBand2.Enabled = true;
if (plantation.nb_of_fruits==0)
{
    DataBand2.Enabled = false;
} else {
    DataBand2.CountData=plantation.nb_of_fruits;
}
Please, look at the attached report template.

Thank you.
Attachments
data.xml
(436 Bytes) Downloaded 218 times
Report.mrt
(5.4 KiB) Downloaded 186 times
Jennypi
Posts: 361
Joined: Mon Nov 17, 2008 7:13 am
Location: France

Re: How to deal with DataCount=0?

Post by Jennypi »

Perfect, thanks a lot.
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

Re: How to deal with DataCount=0?

Post by Andrew »

Hello,

We are glad to help you.

Thank you.
Post Reply