如果有一个名为:lbl的标签警告。当细节带没有任何记录时,我想显示它(Visible = True)。标签位于组页脚中。
答案 0 :(得分:1)
此事件附加到报告本身(在我的示例中,它名为XtraReport1)。 GetCurrentRow()
是XtraReportBase
上的一种方法,它从主报表绑定源返回当前数据。如果数据不存在,则返回null。
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
答案 1 :(得分:0)
目前不在我的开发机器前面,但这样的事情可能会起作用
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