使用 BindingSource 对 ReportViewer 中的报表数据进行排序

发布于 2024-07-11 15:04:25 字数 263 浏览 8 评论 0原文

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

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

我怀疑我错过了一些简单的事情。

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

I'm trying to get ReportViewer to display data from a BindingSource (VB.Net Winforms).

I built the report on the underlying dataset. Then I configured the Data Source Instance to the BindingSource. I thought that would apply the sorting, filtering, etc. But it just looks like the data is coming from the dataset instead of the BindingSource.

I suspect I'm missing something simple.

Update: Or maybe it isn't so simple - I posted this a few days ago and still nobody knows the answer! Maybe I'm trying to do something that can't be done?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

东风软 2024-07-18 15:04:25

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

You'll need to specify the sorting in the report (in the RDL), since it applies its own sorting logic.

放我走吧 2024-07-18 15:04:25

这是我使用的解决方案。 您将 Bi​​ndingSource 中的数据放入 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()

Here's a solution I used. You put the data from the BindingSource into a DataTable and then have the Report use the 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()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文