C# - Loading a Crystal report at runtime...

EFileTahi-A

Well-known member
Joined
Aug 8, 2004
Messages
539
Location
Portugal / Barreiro
The point is to load all my crystal reports from a target directory when the program executes.

How will I do this? I know will need to use the a "stream" object but I cant figure it out.
 
Hi, PlausiblyDamp.

Yeah, that way works out, but not how I would like it to work. I want to load all available reports at once into some "storage" object (HashTable?) so that I can access them when needed, also because, there might be new reports on the target directory when I run the program, thus I cant access directly to a specific report because I dont know the name of the new report...

What I want to do is:

1 - The program loads all reports form a target dir.
2 - I add those reports to a combobox/listview or something. They are identified using their filename.
3 - I choose the report to use from the combobox/listView.
4 - I show for the report by searching it within the reports storage object based on their filename...

I guess I could load all of them to a Report[] array object, but how would I identify them?

I hate Crystal reports...

Let me know if this is confusing... :\
 
Last edited by a moderator:
Could you not load them into a hashtable like you suggested? i.e. On load loop through all .rpt files, for each one found add it to the hashtable using the FileName as the Key and the ReportDocument as the data. (Or use a generic collection if running under .Net 2).

This way you could always refer to an entry in the list by its filename anyway.
 
Well... I tryed the HashTable method but it does not work. I do loaded all reports into the hastable but they would be blank the minute I would tell CrystalReports to display them, and, I made sure the CrystalReports sheets were loaded when I added them to the hashtable...

Anyway, I used a ReportDocument[] array and it worked just fine :). I used then an hashtable to memorize in which array element the report named x would be...

Code:
ReportDocument[] rptDocArr = new ReportDocument[20];
ReportDocument rptDoc = new ReportDocument();

iElement = hashtable[sReportName];
rptDoc = rptDocArr[iElement];

Anyway, thank you for your effort and time PlausiblyDamp. You did helped me with the "Report.Load" thingie which I was missing ;)

- THREAD CLOSED -
 
Last edited by a moderator:

Similar threads

Back
Top