代码之家  ›  专栏  ›  技术社区  ›  JeffO

DevExpress Xtra报告:当明细栏没有任何数据时,如何在组页脚中显示标签?

  •  0
  • JeffO  · 技术社区  · 15 年前

    如果A有一个名为:lblWarning的标签。当细节带没有任何记录时,我想显示它(visible=true)。标签位于组页脚中。

    2 回复  |  直到 14 年前
        1
  •  1
  •   Tom Mayfield    14 年前

    此事件附加到报表本身(在我的示例中,它名为xtrareport1)。 GetCurrentRow() 是一种方法 XtraReportBase 从主报表绑定源返回当前数据。如果数据不存在,则返回空值。

    private void XtraReport1_BeforePrint(object sender, PrintEventArgs e)
    {
        bool noDataFound = GetCurrentRow() == null;
    
        lblWarning.Visible = noDataFound;
    }
    

    VB中的同一个处理程序:

    Private Sub XtraReport1_BeforePrint(ByVal sender As System.Object, ByVal e As PrintEventArgs) Handles MyBase.BeforePrint
        Dim noDataFound As Boolean = GetCurrentRow() Is Nothing
    
        lblWarning.Visible = noDataFound
    End Sub
    
        2
  •  0
  •   AussieALF    15 年前

    目前还没有出现在我的开发人员机器前,不过这样的事情可能会奏效。

    Dim HadRecords As Boolean = False
    
    Private Sub GroupFooter1_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles GroupFooter1.BeforePrint
        If HadRecords = False Then
            lblWarning.visible = True
        Else
            lblWarning.visible = False
            HadRecords = False ' reset the flag '
        End If
    End Sub
    
    Private Sub Detail_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles Detail.BeforePrint
        HadRecords = True ' set the flag '
    End Sub