I’d like to bind a list of objects to a report and show its values.
The sample class looks like this:
class TestClass
{
public string Name { get; set; }
public DateTime Time { get; set; }
public List<int> Numbers { get; set; }
public TestClass(string name, DateTime time)
{
Name = name;
Time = time;
Numbers = new List<int>() { 1, 2, 3, 4, 5 };
}
}
I can bind it to a Microsoft Report Viewer and I can show its values without any problem:
List<TestClass> testClassList = new List<TestClass>()
{
new TestClass("a", DateTime.Now),
new TestClass("b", DateTime.Now.AddHours(1))
};
this.TestClassBindingSource.DataSource = testClassList;
My problem is to show values of the ‘Numbers’ list of my class. I can not add it to the report when designig, and shows ‘error’ in the report. Is it possible to show them in the report?
…and by the way: can I localize somehow reportview controls’s user interface? As I see it supports only English -and may be some more- but not mine.
For the first part, Since the data member is a List of intergets, you would need to serialize them first. You can’t add them directly to the report designer as it is not a simple type.
For part #2:
Here is an example of how to custmize the ReportViewer
http://www.codeproject.com/KB/printing/LocalizingReportViewer.aspx