FlexReport for WPF | ComponentOne
FlexViewer / Binding with FlexReport
In This Topic
    Binding with FlexReport
    In This Topic

    The purpose of binding FlexReport with FlexViewer is to view the FlexReport in FlexViewer control. To bind the FlexReport with FlexViewer control, you first need to create a report definition (.flxr) and load it in C1FlexReport object. Once the report definition is loaded in C1FlexReport, it can be viewed in the FlexViewer control. C1FlexViewer allows you to bind FlexReport with the FlexViewer control using DocumentSource property of C1FlexViewer class. The DocumentSource property takes the value from C1FlexReport object, which contains the report definition.

    Snapshot of FlexViewer

    To preview the report in FlexViewer control, use the following code:

    C#
    Copy Code
    FlexReport flexReport = new FlexReport();
    flexReport.Load(@"../../Resources/FlexDataBinding.flxr", "SimpleData");
    DataSource ds1 = new DataSource();
    ds1.Name = "Main";
    ds1.DataProvider = DataProvider.OLEDB;
    ds1.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Resources\\C1NWind.mdb;Persist Security Info=False";
    ds1.RecordSource = "Products";
    ds1.RecordSourceType = RecordSourceType.TableDirect;
    flexReport.DataSources.Add(ds1);
    flexViewer.DocumentSource = flexReport;