ActiveReports 条件格式 - 图片可见性

发布于 2024-08-25 15:13:56 字数 256 浏览 3 评论 0原文

在 ActiveReports 中,如何根据报表数据中的值更改格式?

具体来说,我想根据数据中的值显示或隐藏图片。报表通过其 DataSource 属性的集合绑定到对象列表。这些对象有一个 Condition 属性,其值为“Poor”、“Normal”等。我在报告中有一些对应于不同条件的图片,并且我想隐藏除与值对应的一个。

我应该订阅详细信息部分的 Format 事件吗?如果是这样,我如何获取“当前记录”数据?

In ActiveReports, how can I change formatting based on values in the report data?

Specifically, I want to show or hide pictures based on a value in the data. The report gets bound to a list of objects via a set to its DataSource property. These objects have a Condition property with values "Poor", "Normal", etc. I have some pictures in the report that correspond to the different conditions, and I want to hide all the pictures except for the one corresponding to the value.

Should I subscribe to the Format event for the detail section? If so, how do I get to the "current record" data?

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

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

发布评论

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

评论(1

或十年 2024-09-01 15:13:56

好吧,我仍然不知道如何获取当前数据对象,但我发现您可以使用报表的 Fields 属性来检索当前数据对象的值。

下面的代码订阅详细信息部分的 Format 事件。 Fields["Condition"].Value 获取当前数据对象的 Condition 属性的值(恰好是一个枚举值)。

< /s>

    private void detail_Format(object sender, EventArgs e)
    {
        Condition? condition = Fields["Condition"].Value as Condition?;

        conditionUnknownPicture.Visible = (condition == Condition.Unknown);
        conditionPoorPicture.Visible = (condition == Condition.Poor);
        conditionNormalPicture.Visible = (condition == Condition.Normal);
        conditionNewPicture.Visible = (condition == Condition.New);
    }

编辑:

我已经了解到从 Format 事件访问 Fields 集合违反了 ActiveReports 设计规则,因为它在某些奇怪的角落不起作用案例。我现在改用这种方法: http://www.datadynamics.com /forums/ShowPost.aspx?PostID=133642#133642

DataDynamics 有一个功能请求 22786,要求提供对 Format 事件中的数据对象的访问。

Ok, I still don't know how to get the current data object, but I discovered that you can use the report's Fields property to retrieve values off the current data object.

The code below subscribes to the detail section's Format event. Fields["Condition"].Value gets the value of the current data object's Condition property (which happens to be an enum value).

    private void detail_Format(object sender, EventArgs e)
    {
        Condition? condition = Fields["Condition"].Value as Condition?;

        conditionUnknownPicture.Visible = (condition == Condition.Unknown);
        conditionPoorPicture.Visible = (condition == Condition.Poor);
        conditionNormalPicture.Visible = (condition == Condition.Normal);
        conditionNewPicture.Visible = (condition == Condition.New);
    }

Edit:

I've since learned that accessing the Fields collection from a Format event is against the ActiveReports design rules, because it doesn't work in certain weird corner cases. I now use this method instead: http://www.datadynamics.com/forums/ShowPost.aspx?PostID=133642#133642

DataDynamics has a feature request 22786 to provide access to the data objects from Format events.

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