If a have a lable called: lblWarning. I'd like to display 开发者_StackOverflow中文版it (Visible = True) when the detail band does not have any records. The label is in the group footer.
This event is attached to the report itself (in my example, it's named XtraReport1). GetCurrentRow()
is a method on XtraReportBase
that returns the current data from the primary report binding source. If data does not exist, it returns null.
private void XtraReport1_BeforePrint(object sender, PrintEventArgs e)
{
bool noDataFound = GetCurrentRow() == null;
lblWarning.Visible = noDataFound;
}
The same handler in 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
Not in front of my dev machine at the moment however something like this may work
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
精彩评论