Polymorphic List

Stimulsoft Reports.NET discussion
Post Reply
Tobias
Posts: 104
Joined: Mon Nov 24, 2008 8:44 am

Polymorphic List

Post by Tobias »

I have a List with items that are derived form TBase but have different types with different properties.

Now I want to print this list with each item beeing a single line. But the formatting of each line should be different for each type derived from TBase.

How can this be done?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Polymorphic List

Post by Alex K. »

Hello,

As a way, you can the following code in BeforePrint events:

Code: Select all

if (VariableFormat == 1)
	DataSource_Filed.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiNumberFormatService(1, ",", 2, " ", 3, true, true, " ");
if (VariableFormat  == 2)
        DataSource_Filed.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiCurrencyFormatService(1, 5, ",", 2, " ", 3, "$.", true, true, " ");
....
Thank you.
Tobias
Posts: 104
Joined: Mon Nov 24, 2008 8:44 am

Polymorphic List

Post by Tobias »

Not exactly what I had in mind. Let's say we have a List with the following items:

- ProductItem(Text, Quantity, Price)
- ProductItem(Text, Quantity, Price)
- DiscountItem(Text, DiscountAmount)
- ProductItem(Text, Quantity, Price)
- VoucherItem(Text, VoucherAmount)

ProductItem, DiscountItem and VoucherItem all derive from SaleItem and I have a data source which is a List.

Now I want that each line looks different depending on the type of item. A ProductItem should show 4 fields - text, quantity, price and total.
DiscountItem should show two fields: text and amount, with e.g. text printed bold. And VoucherItem should have some extra space before
and after, to stick out.

Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Polymorphic List

Post by Alex K. »

Hello,

As a way, you can add a few Child bands to display each type of data, add Conditions and, depending on the type, to display only the necessary one.

Thank you.
Tobias
Posts: 104
Joined: Mon Nov 24, 2008 8:44 am

Polymorphic List

Post by Tobias »

Ok.

And is there a way to get a type column to be used in the condtion when registering a List? Or will I have to kinda wrap the list items to provide such a column?

Tobias
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

Polymorphic List

Post by Andrew »

Hello,
And is there a way to get a type column to be used in the condtion when registering a List? Or will I have to kinda wrap the list items to provide such a column?
Sorry, maybe we did not exactly understand your question.
As a way you may add an additional column - as an indicator of data types column and use this column in a condition.

Thank you.

Post Reply