FieldListDockPanel.UpdateDataSource(IDesignerHost) Method
Forcibly updates the structure of data sources currently displayed within this FieldListDockPanel object.
Namespace: DevExpress.XtraReports.UserDesigner
Assembly: DevExpress.XtraReports.v26.1.Extensions.dll
NuGet Package: DevExpress.Win.Reporting
Declaration
Parameters
| Name | Type | Description |
|---|---|---|
| designerHost | IDesignerHost | An object implementing the IDesignerHost interface that is used to manage designer transactions and components. |
Remarks
The first step in troubleshooting field update problems is to verify that the data source and data member settings are correct. You can also call the data source’s RebuildResultSchema method.
Use the UpdateDataSource method only in special cases such as when a report’s data source is changed, but this change isn’t reflected in the Field List, and it is necessary to update the Field List.
Example
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., List<T>), as demonstrated in the following sample.
The code uses the ReportDesignTool instance that invoked the End-User Report Designer. If you show the designer without a ribbon (the ShowDesigner method), use the DesignForm property instead of DesignRibbonForm.
Imports System.ComponentModel.Design
Imports DevExpress.XtraReports.UI
Imports DevExpress.XtraReports.UserDesigner
' ...
Private designTool As ReportDesignTool
' ...
designTool = New ReportDesignTool(New XtraReport1())
designTool.ShowRibbonDesigner()
' ...
Private Sub BindReportToData()
Dim designPanel As XRDesignPanel = designTool.DesignRibbonForm.DesignMdiController.ActiveDesignPanel
If designPanel?.Report Is Nothing Then
Return
End If
' Create a data source and bind it to the report.
designPanel.Report.DataSource = CreateDataSource()
' Update the Field List.
Dim fieldList As FieldListDockPanel = _
CType(designTool.DesignRibbonForm.DesignDockManager(DesignDockPanelType.FieldList), FieldListDockPanel)
Dim host As IDesignerHost = CType(designPanel.GetService(GetType(IDesignerHost)), IDesignerHost)
fieldList.UpdateDataSource(host)
End Sub