# C1Report to FlexReport Breaking Changes

Get started with FlexReport, a WinForms control, which is a fast-paced reporting engine that enables you to create, preview, export and print modern and dynamic reports for all your applications. See more in documentation here.

## Content

FlexReport code has been written from scratch; as a result, you will find following breaking changes in the API on migrating from C1Report to FlexReport:

* In C1Report, parameters can only be specified directly in the **DataSource.RecordSource**, immediately before the SQL statement and after the key word PARAMETERS.
<br>
    In FlexReport, there is a separate dedicated report-level collection [C1FlexReport.Parameters](/componentone/docs/wpf/online-flexreport/), where the report parameters can be specified. When importing a C1Report report definition from a .xml file, any parameters specified old-style using PARAMETERS keyword are automatically added to the **C1FlexReport.Parameters** collection.
* In FlexReport, the **OnOpen** script is fired AFTER the data source has been opened, so any changes to the main data source made in that script does not affect the report. In order to change something in the data source before the report is generated, use **GlobalScripts**. GlobalScripts can contain function and procedure definitions, and codes that are not within these definitions; all such definitions and codes are now executed when the report starts rendering, before the data source is opened.
* In C1Report, Custom fields derived from **Field** overrides the **GetRenderContent()** method. The method's signature in C1FlexReport has been changed to:

    ```auto
      public virtual void GetDesignerRenderContent(  ref string text,  ref Image image,  ref bool disposeImage);
    ```

    If the overriding method sets disposeImage to true, C1FlexReport calls **Dispose()** on the image after it has been used.
* The **C1Report.OutlineRootLevel** property has been removed. To control the outline structure, use properties [OutlineLabel](/componentone/docs/wpf/online-flexreport/) and [OutlineParent](/componentone/docs/wpf/online-flexreport/). To turn off outlines generated by a subreport, use the [SubreportField.OutlinesVisible](/componentone/docs/wpf/online-flexreport/) property.
* In C1Report, there are two slightly different methods to generate/layout text - default and 'gdi+' (if
    **C1Report.UseGdiPlusTextRendering** were set to true - non-default). These methods can produce slightly different text layouts, e.g. line breaks could be in different places etc. FlexReport always generates/lays out text like C1Report with UseGdiPlusTextRendering set, but still there may be differences in line breaks between C1Report with UseGdiPlusTextRendering set, and FlexReport.
* The **AddOutlineEntry** event has been removed. To change the text of the outline entry generated by a field/section/sub-section, use the **OutlineLabel** property.
* A new specialized event type has been added for the **C1FlexReport.ReportError** event: **ReportErrorEventHandler**, accepting **ReportErrorEventArgs** event arguments. The ReportEventArgs type has been modified - Exception and Handled have been removed from the event arguments.
* If a report contains Map custom field(s), it must be generated synchronously (call **Render()** rather than **RenderAsync()**), else the map field cannot be displayed in the FlexViewer control. You should set the **FlexViewer.UseAsyncRendering** property to False.
* In C1Report, EndReport event is not fired in case of an error. In FlexReport, the **EndReport** event is fired even if a fatal error occurs during rendering.
* Following C1Report methods/properties have been removed from C1FlexReport:
    * C1Report.Document.Generate()
    * C1Report.Document.Export()
    * C1Report.Document.CreationDpi
    * C1Report.DocumentInternal
    * C1Report.Document.DoEvents
    * C1Report.Document.HasEditableTags
    * C1Report.CreationDevice
    * StartReport(), StartSection(), EndSection(), RenderField()
    * C1Report.DataSource.DataObject: In C1FlexReport, the same can be accessed through [DataSource.Recordset](/componentone/docs/wpf/online-flexreport/) property.
    * C1Report.EmfType: In C1FlexReport, use EMF+ instead.
    * C1Report.GetReportInfo(): In C1FlexReport, use [C1FlexReport.ReportInfo](/componentone/docs/wpf/online-flexreport/) instead.
    * C1Report.PageRenderingMode: In C1FlexReport, use **C1FlexReport.GetPageImage** in order to get a page’s metafile.
* C1Report Render\<X> method cannot be accessed in code behind with C1FlexReport. These methods are for internal use.
* C1Report Render\<X> object cannot be used by using following code:
<br>
    `c1Report1.Document.Body.Children.Add(RenderGraphic obj)`
<br>
    This method is not supported in FlexReport.
* **C1FlexReport.Document** cannot be converted to System.Drawing.Printing.PrintDocument. PrintDocument should not be used with FlexReport since PrintDocument's **C1Report.Document** property does not exist.
* In FlexReport, **IC1FlexReportRecordset** does not have ApplyFilter() and ApplySort() methods. Instead, DataSource in FlexReport has filters/sort definition, so these should be used. IC1FlexReportRecordset is assigned to **DataSource.Recordset** while filters/sorts can be defined on the DataSource.
* C1Report’s **FieldBase** object can no longer be used with FlexReport.
<br>
    Field is a 'legacy' type with C1FlexReport. Now specialized types are derived from FieldBase in C1FlexReport. Following field objects should be directly created in code-behind:
    * TextField text = new TextField();
    * BarCodeField barcode = new BarCodeField();
    * SubreportField subreport = new SubreportField();
    * ChartField chart = new ChartField();
    * RTFField rtf=new RTFField();
    * CheckBoxField checkbox = new CheckBoxField();
    * CalculatedField calField=new CalculatedField();
    * ImageField img = new ImageField();
    * ShapeField shape = new ShapeField();

    Use corresponding properties, same as used to be set for C1Report FieldBase object.
* CanGrow and CanShrink properties of C1Report have been renamed in C1FlexReport. Use [C1FlexReport.AutoHeight](/componentone/docs/wpf/online-flexreport/), [C1FlexReport.AutoWidth](/componentone/docs/wpf/online-flexreport/), and [C1FlexReport.AutoSizeBehavior](/componentone/docs/wpf/online-flexreport/) instead. CanGrow=True and CanShrink=True can be used as **C1FlexReport.AutoSizeBehavior.GrowAndShrink**.
* In FlexReport, instead of the **AddScriptObject** event there is [GetScriptObject](/componentone/docs/wpf/online-flexreport/) event. So in this case, instead of

    ```auto
    
    private void c1flxr_StartReport(object sender, System.EventArgs e)
    {  
       c1flxr.AddScriptObject("LookUp", new LookUpObject());
    }
    ```

    ```auto
    c1flxr.GetScriptObject += c1flxr_GetScriptObject;
    ...
    void c1flxr_GetScriptObject(object sender, C1.Win.FlexReport.ReportGetScriptObjectEventArgs e)
    {  
       if (e.Name.ToLower() == "lookup")    
         e.Object = new LookUpObject();
    }
    ```
* C1FlexReport caches rendered content and does not regenerate a report if the report template is not changed. To ensure that report is regenerated, you can call **C1FlexReport.SetDirty()** method.