views:

560

answers:

3

I want to create a report, using either Crystal reports or RDLC, doesn't really matter which. I can get all the data sources together as a series of dynamically generated textboxes etc, but how do I add that to a report?

Eg I want customer name and all of their ordered items in a report. Now I can get all of the information in an array... how would I then place that into a Crystal Report?

Any good introductions that cover non-wizards for Crystal Reports would be amazing. Any other recommendations would be great too.

+3  A: 

Every datasource of your report has a name (menu report->datasources, It can be not exact because my vs is not in English).

Supose that one of your datasources name is prj_folder_classSample, and classSample is a class of your project. Then you need to add a List to the report.

Let's do it.

List<classSanple> lst = new List<classSample>
lst.Add(...) //Add various instances of classSample
BindingSource thisIsABindingSource = new BindingSource();
thisIsABindingSource.DataSource = lst;
reportDataSource rds = new ReportDataSource("prj_folder_classSample", thisIsABindingSource);

ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.EnableExternalImages = true;
ReportViewer1.LocalReport.ReportEmbeddedResource = "YourProject.Folder.reportName.rdlc";
ReportViewer1.LocalReport.DataSources.Add(rds)

I do it in this way. Hope It helps you.

Jonathan
This looks good and all, but how would I then change the display of the report - where things are displayed etc.
David Archer
Go to a textbox in the report designer, seach for the property named value. The first option is Expression. It will open a expresion designer. There is a section named Categories, and inside there is a category (dataset, datasource or something like this) with all the datasources that you have added to your report. Select a datasource and a field of this datasource, and then the field will display the selected value in runtime.
Jonathan
So there's no way to just assign values, like Report.Textbox1 = Form.Textbox1?
David Archer
If there is a way... I don't know it. Sorry. But you can also pass params to a report.
Jonathan
You can set the value of a TextBox dynamically (with RDLC)
Rookian
How? Any sites you can recommend to explain more about this?
David Archer
A: 

Look at this link http://msdn.microsoft.com/en-us/library/cc281022.aspx#RDCE if you want to dynamically change your report. This extension is called just before the report is rendered. Microsoft has created a RDL Object Model. With this one you can customize your whole report. But maybe you don't need this extension. Just try first your stuff in the Report Designer.

Rookian
A: 

Hi, With FastReport .NET you can create a System.Data.DataSet based on your information, and then you can add this DataSet to report by following code:

report.RegisterData(dataset);
programer256