Search code examples
c#devexpressxtrareport

Trying to display a list property in XtraReport


I'm trying to display a class object on a XtraReport.

public class Data
{
    public SubData DataOne { get; set; }
    public SubData DataTwo { get; set; }

    public Data(SubData dataOne, SubData dataTwo)
    {
        DataOne = dataOne;
        DataTwo = dataTwo;
    }
}

public class SubData
{
    public string Value { get; set; }
    public List<string> ValueList { get; set; }

    public SubData(string value, params string[] moreValues)
    {
        Value = value;
        ValueList = new List<string>();
        if (moreValues != null)
            ValueList.AddRange(moreValues);
    }
}

I want to display the data on a ReportView (DocumentView): public List Data;

    public Form1()
    {
        InitializeComponent();
        Data = new List<Data>();
        Data.Add(new Data(
                new SubData("A", "1", "2"),
                new SubData("V", "101", "102", "103")));
        Data.Add(new Data(
                new SubData("B", "3", "4"),
                new SubData("W", "201", "202", "203", "204")));
        Data.Add(new Data(
                new SubData("C", "5", "6"),
                new SubData("X", "AB", "CD", "EF", "GH")));
        Data.Add(new Data(
                new SubData("D", "7", "8"),
                new SubData("Y", "3", "5", "7", "11")));
        Data.Add(new Data(
                new SubData("E", "9", "10"),
                new SubData("Z", "<", "<<", "<<<", "<<<<")));


        var report = new XtraReport1();
        report.DataSource = Data;
        documentViewer1.DocumentSource = report;
    }

When i create an XtraReport, bound to the class "Data", i fail to display the list of strings. I want to display all elements of the list on the report.

When i create a new Report via ReportWizard, i can only place the Length of "ValueList" on the report designer.

Available Data Fields

Placing the "ValueList"-Field itself on the report will always put "Length" on the report designer form.

How can i display all values in the report?

E.g. for the first entry:

A  1,2
V  101,102,103

Solution

  • Apparently, List disables XtraReport to access the element via Designer...

    If i use List with StringData:

    public class StringData {
        public String S {get; set;}
    }
    

    ... i can use the string S and thus display the list of values.