Relatório Devexpress Xtra: Como exibir uma etiqueta no rodapé do grupo quando a banda de detalhes não possui nenhum dado?
-
11-09-2019 - |
Pergunta
Se um tiver uma fatura chamada: lblwarning. Eu gostaria de exibi -lo (visível = true) quando a banda detalhada não possui nenhum registro. A etiqueta está no rodapé do grupo.
Solução
Este evento está anexado ao próprio relatório (no meu exemplo, ele se chama XTRAREPORT1). GetCurrentRow()
é um método em XtraReportBase
Isso retorna os dados atuais da fonte de ligação do relatório primário. Se os dados não existirem, retornará nulo.
private void XtraReport1_BeforePrint(object sender, PrintEventArgs e)
{
bool noDataFound = GetCurrentRow() == null;
lblWarning.Visible = noDataFound;
}
O mesmo manipulador em 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
Outras dicas
Não na frente da minha máquina de desenvolvimento no momento, mas algo assim pode funcionar
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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow