简体   繁体   English

使用清单 <T> 在Microsoft报表查看器中

[英]Using list<T> in Microsoft Report Viewer

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: 我可以将其绑定到Microsoft Report Viewer,并且可以毫无问题地显示其值:

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? ...以及顺便说一句:我可以以某种方式本地化reportview控件的用户界面吗? 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. 对于第一部分,由于数据成员是一个Interget列表,因此您需要先对其进行序列化。 You can't add them directly to the report designer as it is not a simple type. 您不能将它们直接添加到报表设计器中,因为它不是一个简单的类型。

For part #2: 对于第2部分:

Here is an example of how to custmize the ReportViewer 这是一个如何自定义ReportViewer的示例

http://www.codeproject.com/KB/printing/LocalizingReportViewer.aspx http://www.codeproject.com/KB/printing/LocalizingReportViewer.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM