Reports for WinForms | ComponentOne
Working with C1Report / Loading, and Rendering the Report / Loading Report Data / Using Custom Data Source Objects
In This Topic
    Using Custom Data Source Objects
    In This Topic

    You can use custom objects as data sources. The only requirement is that the custom object must implement the IC1ReportRecordset interface.

    IC1ReportRecordset is a simple and easy-to-implement interface that can be added easily to virtually any collection of data. This is often more efficient than creating a DataTable object and copying all the data into it. For example, you could use custom data source objects to wrap a file system or custom XML files.

    To use a custom data source objects, load the report definition and then assign the object to the C1Report's Recordset property. For example:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    ' get custom data source object        
    Dim rs As IC1ReportRecordset = CType(GetMyCustomDataSource(), IC1ReportRecordset)
    
    ' load report definition (before setting the data source)        
    c1r.Load(reportFile, reportName)
    
    ' use custom data source object in C1Report component        
    c1r.DataSource.Recordset = rs
    

    To write code in C#

    C#
    Copy Code
    // get custom data source object        
    IC1ReportRecordset rs = (IC1ReportRecordset)GetMyCustomDataSource();
            
    // load report definition (before setting the data source)        
    c1r.Load(reportFile, reportName);
        
    // use custom data source object in C1Report component        
    c1r.DataSource.Recordset = rs;