The requested page is not available for the requested platform. You are viewing the content for Default platform.

Refresh the Field List in the End-User Report Designer

  • 2 min to read

This document describes how to refresh the Field List after updating a report's data source in the End-User Report Designer for WinForms.

Update the Data Source

The following code demonstrates how to update the Field List in the End-User Report Designer by calling the FieldListDockPanel.UpdateDataSource method after assigning a data source to a report.

This may be required after a report has been assigned a new data source at runtime without adding this data source to the End-User Report Designer host. For example, this situation occurs when binding to a list data source (e.g., ArrayList), as demonstrated in the following sample.

Private Sub BindReportToData()
    If xrDesignPanel1.Report Is Nothing Then
        Return
    End If
     ' Create a data source and bind it to a report.
    xrDesignPanel1.Report.DataSource = CreateDataSource()

    ' Update the Field List.
    Dim fieldList As FieldListDockPanel = CType(xrDesignDockManager1(DesignDockPanelType.FieldList), FieldListDockPanel)
    Dim host As IDesignerHost = CType(xrDesignPanel1.GetService(GetType(IDesignerHost)), IDesignerHost)
    fieldList.UpdateDataSource(host)
End Sub

Refresh the Data Source Information

When updating a data source structure (e.g., by adding new tables and/or columns to the DataSet/DataTable, or by changing the object assigned to the BindingSource.DataSource property), use the following code for clearing the Data Context cache.

private void BindReportToData() {
    if (xrDesignPanel1.Report == null)
        return;
     // Create a data source and bind it to a report.
    xrDesignPanel1.Report.DataSource = CreateDataSource();

    // Update the Field List.
    FieldListDockPanel fieldList =
        (FieldListDockPanel)xrDesignDockManager1[DesignDockPanelType.FieldList];
    IDesignerHost host = 
        (IDesignerHost)xrDesignPanel1.GetService(typeof(IDesignerHost));

    // Clear the Data Context cache.
    ((DataContextServiceBase)host.GetService(typeof(IDataContextService))).Dispose();

    fieldList.UpdateDataSource(host);
}