List<string> as variable (*resolved*)

Stimulsoft Reports.NET discussion
Post Reply
EduardoSilva
Posts: 5
Joined: Mon Jul 05, 2010 6:56 am
Location: Germany

List<string> as variable (*resolved*)

Post by EduardoSilva »

Hello!

I am a newbie :)

I have a report which actually shows only different data from different objects, one for every type. So: Organisation.Name, Organisation.Code, Ticket.Number ... only one. So I have decided to build variables: OrganisatioName, OrganisationCode, TicketNumber ... and simply assign them one by one. Seemed less complex as defining the business objects within the report.

But... one property is a List .

Now, I can of course "string[].Join()" it, and then assign it, and in the report I "string.Split" it and then use the elements in a used-defined function, which returns what I actually want to present. Ok.

But, if I do this, I will have to use a special char or combination of chars in the program which uses the report, to separate the strings. And I feel unconfortable about this, because those strings come from the end-user. I would prefer to avoid a "coding / decoding" of any kind. I very much would like to be able to say something like:

StiReport report = new StiReport();
report.Load(...);
report.Compile();
(...)
report["Attendees"] = new List { "att1", "att2" }; // Of course the real list of strings comes from elsewhere.
(...)
report.Render();

How can I go as near as possible from this, how should I define the list of strings in the report designer, so that I use it as a list of strings (or similar) there, and assign it as such in the main project which renders the report?

If you can help, I would be grateful :)

Bye!

==========

Update: I actually came up with it:

using System.Collections.Generic;
(...)
public List Attendees { get; set; }

In the report, then I can really write:

report["Attendees"] = new List {"firstone", "secondone"};

In the using project.

I have no more preview :( but I think I can fight to correct this, and it is anyway another subject matter.
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

List<string> as variable (*resolved*)

Post by Ivan »

Hello,

Please try to use the following code:

Code: Select all

List Attendees = new List( new string[] {"One", "Two", "Three"} );
Thank you.
Attachments
495.Report sample.mrt
(3.45 KiB) Downloaded 407 times
Post Reply