如何在另一个未绑定报表中创建未绑定子报表

发布于 2024-08-05 21:16:36 字数 1404 浏览 9 评论 0 原文

我有一个未绑定的 XtraReport,它有一个子报表控件,其中包含另一个报表。我将使用架构定义字段的报表称为“未绑定”,但实际上并未绑定到任何数据集,我使用数据访问层创建一个数据表,然后将该对象传递到报表的 DataSource 属性。

所以,我有以下代码:

        // (...) Get the data from the db and fill a DataTable

        if (table.Rows.Count > 0)
        {
            report.DataSource = table;

            // (...) Get the data from the db and fill a DataTable for the subreport
            report.SubPurchaseOrder.Report.DataSource = tableSubReport;

            report.ShowPreviewDialog();
        }
        else
        {
            MessageBox.Show("No data to show.");
        }

但是使用这种方法得到的子报告打印得非常奇怪(看看 附加 pdf,抱歉它是西班牙语,但我想你明白了)。

我已经阅读了 DevExpress 文档,也许我没有得到正确的方法,所以我向您提出的问题是如何创建一个包含一个或多个子报告的报告,但我必须使用外部的某些流程提供数据来填充它们报告,例如数据访问层?

如果问题表述不正确或缺少更多信息,请告诉我。

编辑:

我在此处上传了一个包含问题报告的示例项目。

我尝试过使用某种参数。在子报表控件的 BeforePrint 事件中,我尝试了:

((XRSubreport)sender).ReportSource.FilterString = "[IdPO_RO] = " + _idPurchaseOrder;

当然

((XRSubreport)sender).ReportSource.Parameters["Id"].Value = _idPurchaseOrder;

,对于第二个,我添加了一个参数和与第一个相同的过滤字符串,但使用了该参数。

I have an unbound XtraReport that has a subreport control which contains another report. I call "unbound" to a report that has the definition of the fields using a schema but not actually bound to any DataSet, I create a DataTable using a Data Access Layer and then pass that object to the DataSource property of the report.

So, I have the following code:

        // (...) Get the data from the db and fill a DataTable

        if (table.Rows.Count > 0)
        {
            report.DataSource = table;

            // (...) Get the data from the db and fill a DataTable for the subreport
            report.SubPurchaseOrder.Report.DataSource = tableSubReport;

            report.ShowPreviewDialog();
        }
        else
        {
            MessageBox.Show("No data to show.");
        }

But what I get using this approach is the subreport printed very oddly (take a look at the attached pdf, sorry it's in spanish but I think you get the idea).

I've read the DevExpress documentation and maybe I'm not getting the approach right, so my question to you is how to create a report that has one or more subreports but I have to provide the data to fill them using some process external to the reports, such as a Data Access Layer?

Please let me know if the question is not stated correctly or lacks of more info.

EDIT:

I uploaded a sample project with the report with problem here.

I've tried to use parameters of some kind. In the BeforePrint event of the subreport control, I tried:

((XRSubreport)sender).ReportSource.FilterString = "[IdPO_RO] = " + _idPurchaseOrder;

and

((XRSubreport)sender).ReportSource.Parameters["Id"].Value = _idPurchaseOrder;

Of course, for the second, I added a parameter and the filter string the same as the first but using the parameter.

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

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

发布评论

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

评论(1

遇见了你 2024-08-12 21:16:36

我可以解决这个问题。

造成这种情况的原因是我分配给了错误的对象。这一行:

report.SubPurchaseOrder.Report.DataSource = tableSubReport;

应该是:

report.SubPurchaseOrder.ReportSource.DataSource = tableSubReport;

所以简单的解释是我使用另一个属性来引用子报表控件(XRSubreport)中包含的报表。

I could solve the problem.

The cause for this was that I was assigning to the wrong object. This line:

report.SubPurchaseOrder.Report.DataSource = tableSubReport;

should be:

report.SubPurchaseOrder.ReportSource.DataSource = tableSubReport;

So the brief explanation is that I was using another property to refer to the report contained in the subreport control (XRSubreport).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文