【问题标题】:Sum the value of two labels in devexpress xtrareports将 devexpress xtrareports 中两个标签的值相加
【发布时间】:2015-08-26 16:31:27
【问题描述】:

如果有办法我可以从两个标签中得到一个总和并在第三个标签中显示结果。现在,我的一份报告中的总和一直存在问题,如果有办法可以对标签进行求和而不是计算字段,我想我可以解决我的问题。

我正在调查此事,我在论坛中发现了类似的问题,但他们给出的回复并没有解决我的问题。 以下是问题的链接: https://www.devexpress.com/Support/Center/Question/Details/Q316239 https://www.devexpress.com/Support/Center/Question/Details/Q470883

我正在使用 c# 在 Visual Studio 2012 中处理报告,我的 DevExpress 版本是 14.1。

【问题讨论】:

    标签: c# asp.net devexpress


    【解决方案1】:

    您可以使用XRControl.BeforePrint 事件。在这种情况下,您可以简单地更改标签的文本。您可以从其他标签中获取文本:

    private void xrLabel3_BeforePrint(object sender, PrintEventArgs e)
    {
        xrLabel3.Text = (int.Parse(xrLabel1.Text) + int.Parse(xrLabel2.Text)).ToString();
    }
    

    您也可以使用XtraReportBase.GetCurrentColumnValue 方法获取当前值:

    private void xrLabel3_BeforePrint(object sender, PrintEventArgs e)
    {
        xrLabel3.Text = (GetCurrentColumnValue<int>("FirstValue") + GetCurrentColumnValue<int>("SecondValue")).ToString();
    }
    

    并且可以使用XtraReportBase.GetCurrentRow方法获取底层数据对象:

    private void xrLabel3_BeforePrint(object sender, PrintEventArgs e)
    {
        var yourData = (YourDataClass)GetCurrentRow();
        xrLabel3.Text = (yourData.FirstValue + yourData.SecondValue).ToString();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多