DevExpress Xtra Informe: Cómo mostrar una etiqueta en el pie de grupo cuando la banda de detalle no tiene ningún dato?

StackOverflow https://stackoverflow.com/questions/1828308

  •  11-09-2019
  •  | 
  •  

Pregunta

Si una tiene una etiqueta llamada: Advertencia LBL. Me gustaría mostrarlo (Visible = True) cuando la banda de detalle no tiene ningún registro. La etiqueta se encuentra en el pie de grupo.

¿Fue útil?

Solución

Este evento se adjunta al informe en sí (en mi ejemplo, es llamado XtraReport1). GetCurrentRow() es un método en XtraReportBase que devuelve los datos de corriente de la fuente de unión informe principal. Si no existen datos, se devuelve un valor nulo.

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

    lblWarning.Visible = noDataFound;
}

El mismo controlador en 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

Otros consejos

No delante de mi máquina dev en el momento sin embargo algo como esto puede trabajar

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 bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top