Polymorphic List
Polymorphic List
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?
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?
Polymorphic List
Hello,
As a way, you can the following code in BeforePrint events:
Thank you.
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, " ");
....
Polymorphic List
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.
- 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.
Polymorphic List
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.
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.
Polymorphic List
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
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
Polymorphic List
Hello,
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.
Sorry, maybe we did not exactly understand your question.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?
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.