If a have a lable called: lblWarning. I'd like to display it (Visible = True) when the detail band does not have any records. The label is in the group footer.
views:
831answers:
2
A:
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
AussieALF
2009-12-03 03:11:13
The group header/footer bands do not have a setting to print when there is no record, so this sub would not be executed.
Jeff O
2009-12-03 14:57:40
+1
A:
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
Thomas G. Mayfield
2010-02-11 15:30:48