Vb.net 使用BindingSource在ReportViewer中对报表数据进行排序

Vb.net 使用BindingSource在ReportViewer中对报表数据进行排序,vb.net,ado.net,reportviewer,bindingsource,Vb.net,Ado.net,Reportviewer,Bindingsource,我试图让ReportViewer显示来自BindingSource(VB.Net Winforms)的数据 我在底层数据集上构建了报告。然后,我将数据源实例配置为BindingSource。我认为这将应用排序、过滤等,但看起来数据来自数据集,而不是BindingSource 我怀疑我遗漏了一些简单的东西 更新:或者可能不是那么简单-我几天前发布了这篇文章,但仍然没有人知道答案!也许我正在尝试做一些无法完成的事情?您需要在报告中指定排序(在RDL中),因为它应用自己的排序逻辑。我使用了一个解决方案

我试图让ReportViewer显示来自BindingSource(VB.Net Winforms)的数据

我在底层数据集上构建了报告。然后,我将数据源实例配置为BindingSource。我认为这将应用排序、过滤等,但看起来数据来自数据集,而不是BindingSource

我怀疑我遗漏了一些简单的东西


更新:或者可能不是那么简单-我几天前发布了这篇文章,但仍然没有人知道答案!也许我正在尝试做一些无法完成的事情?

您需要在报告中指定排序(在RDL中),因为它应用自己的排序逻辑。

我使用了一个解决方案。将BindingSource中的数据放入DataTable,然后让报表使用DataTable

    ReportViewer1.Reset()
    Dim dt As DataTable
    dt = DirectCast(Form1.ProgActnBindingSource.Current, DataRowView).DataView.ToTable

    Dim rs = New ReportDataSource
    rs.Name = "name"
    rs.Value = dt

    ReportViewer1.ProcessingMode = ProcessingMode.Local
    ReportViewer1.LocalReport.DataSources.Clear()
    ReportViewer1.LocalReport.DataSources.Add(rs)
    ReportViewer1.LocalReport.ReportEmbeddedResource = "projectname.Report1.rdlc"

    Me.ReportViewer1.RefreshReport()