views:

566

answers:

1

Hi,

Can anyone provide a Code Snippet, Tutorial link or information on how to create a report in Microsoft Report from a List of objects?

I have the following Dog class:

namespace MyNS
{
   public class Dog
   {
      public int Legs { get; set; }
      public string Name { get; set; }
      public string Breed { get; set; }
   }
}

Then, in Window Forms, I have a ReportViewer objetct which I would like to populate from a List of MyNS.Dog objects like this:

List<MyNS.Dog> MyDogs = new List<MyNS.Dog>();
// populate array here
// and use it as datasource for ReportViewer

Any ideas?

Thanks!

+2  A: 

For a local report, you can specify your data source like this:

var reportViewer = New ReportViewer();
var reportDataSource = New ReportDataSource("MyNS_Dog", MyDogs);
reportViewer.LocalReport.DataSources.Add(reportDataSource);
Meta-Knight
Awesome. Going to try and will let you know.
Pablo Santa Cruz
If I wanted these items in a textbox in a list what would the parameters be for those textboxes in the report (RDLC) itself?
Matthew Lock